Hi,
This is less of an error, and more of an "I cant workout how to do this" I have spent the past 45 minutes on google and just can't seem to get it right.
I have to refer to two workbooks & copy data in between them, and instead of naming the worksheet explicitely everytime, I want to name each worksheet as a variable down from the workbook error. I have tried many different thins & declarations but just can't seem to get it right. This is how it looks presently, and it is not working.
This is less of an error, and more of an "I cant workout how to do this" I have spent the past 45 minutes on google and just can't seem to get it right.
I have to refer to two workbooks & copy data in between them, and instead of naming the worksheet explicitely everytime, I want to name each worksheet as a variable down from the workbook error. I have tried many different thins & declarations but just can't seem to get it right. This is how it looks presently, and it is not working.
Code:
Sub ImportTNTInfo()
Dim lRow As Long
Dim TNTWb As Workbook
Dim BillingWb As Workbook
Dim WS As Worksheet
Dim TNTSheet As String
TNTSheet = "C:\TNT\File.csv"
Workbooks.Open (TNTSheet)
TNTWb = Workbook("File.csv")
BillingWb = Workbook("AU-EI Billing Sheet")
WS = Worksheets(1)
lRow = TNTWb.WS.Range("A1").End(xlDown).Row
'** Import Shiprefs **'
TNTWb.WS.Range("I2:I" & lRow).Copy BillingWb.WS.Range("E10")
'** Import Address **'
TNTWb.WS.Range("M2:M" & lRow).Copy BillingWb.WS.Range("F10")
'** Import Suburb **'
TNTWb.WS.Range("N2:N" & lRow).Copy BillingWb.WS.Range("G10")
'** Import Postal Code **'
TNTWb.WS.Range("O2:O" & lRow).Copy BillingWb.WS.Range("H10")
'** Import State **'
TNTWb.WS.Range("P2:P" & lRow).Copy BillingWb.WS.Range("I10")
'** Import Customer Name **'
TNTWb.WS.Range("M2:M" & lRow).Copy BillingWb.WS.Range("K10")
End Sub