RaunLGoode
Registered User.
- Local time
- Today, 07:59
- Joined
- Feb 18, 2004
- Messages
- 122
I can import data from a table on one file into another using ADO
Using the following lines of code without any issues
xRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
tArray = ReadDataFromWorkbook("H:\InvoiceFolder\Invoice 123.xls", "InvoiceData")
For r = LBound(tArray, 1) To UBound(tArray, 2)
For c = LBound(tArray, 1) To UBound(tArray, 1)
Range("A" & xRow).Select
'dArray.Select
ActiveCell.Offset(r, c).Formula = tArray(c, r)
Next c
Next r
But what I really want to do is replace the Path and File name with variables, so I am trying the following code which returns an error
xRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Array = ReadDataFromWorkbook(TargetPath & " \ " & TargetInvoice & ", " & "InvoiceData")
For r = LBound(tArray, 1) To UBound(tArray, 2)
For c = LBound(tArray, 1) To UBound(tArray, 1)
Range("A" & xRow).Select
'dArray.Select
ActiveCell.Offset(r, c).Formula = tArray(c, r)
Next c
Next r
I checked the variables, they appear to be correct. Writing the String produced by [TargetPath & " \ " & TargetInvoice & ", " & "InvoiceData] statement looks looks identical to
“H:\InvoiceFolder\Invoice 123.xls", "InvoiceData “
Is there some reason why I cant use variables in this ststement?
Using the following lines of code without any issues
xRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
tArray = ReadDataFromWorkbook("H:\InvoiceFolder\Invoice 123.xls", "InvoiceData")
For r = LBound(tArray, 1) To UBound(tArray, 2)
For c = LBound(tArray, 1) To UBound(tArray, 1)
Range("A" & xRow).Select
'dArray.Select
ActiveCell.Offset(r, c).Formula = tArray(c, r)
Next c
Next r
But what I really want to do is replace the Path and File name with variables, so I am trying the following code which returns an error
xRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Array = ReadDataFromWorkbook(TargetPath & " \ " & TargetInvoice & ", " & "InvoiceData")
For r = LBound(tArray, 1) To UBound(tArray, 2)
For c = LBound(tArray, 1) To UBound(tArray, 1)
Range("A" & xRow).Select
'dArray.Select
ActiveCell.Offset(r, c).Formula = tArray(c, r)
Next c
Next r
I checked the variables, they appear to be correct. Writing the String produced by [TargetPath & " \ " & TargetInvoice & ", " & "InvoiceData] statement looks looks identical to
“H:\InvoiceFolder\Invoice 123.xls", "InvoiceData “
Is there some reason why I cant use variables in this ststement?