J
John
I have to worksheets that have the same layout in two different files... I
want to open one to load the data into the current workbook... I get errors
on twbk = thisworkbook
Sub loadTickerFile()
Dim twbk As Workbook
twbk = ThisWorkbook
If Worksheets("Long Term Ticket").Range("D2").Value = "" Then
MsgBox "Please enter ticker in Range D2 and re-run macro."
GoTo ender:
End If
User = Environ("UserProfile")
file = User & "\" & "My Documents\Trade Tickets\Long Term Ticket " &
Worksheets("Long Term Ticket").Range("D2").Value
Workbooks.Open file
Dim wbk As Workbook
wbk = ActiveWorkbook
twbk.Sheets("Long Term Ticket").Range("e4:e14") = wbk.Sheets("Long Term
Ticket").Range("e4:e14")
twbk.Sheets("Long Term Ticket").Range("D2022") = wbk.Sheets("Long Term
Ticket").Range("D2022")
twbk.Sheets("Long Term Ticket").Range("D2837") = wbk.Sheets("Long Term
Ticket").Range("D2837")
twbk.Sheets("Long Term Ticket").Range("D4050") = wbk.Sheets("Long Term
Ticket").Range("D4050")
twbk.Sheets("Long Term Ticket").Range("h4:h50") = wbk.Sheets("Long Term
Ticket").Range("h4:h50")
wbk.Close savechanges:=False
ender:
Range("A2").Select
End Sub
want to open one to load the data into the current workbook... I get errors
on twbk = thisworkbook
Sub loadTickerFile()
Dim twbk As Workbook
twbk = ThisWorkbook
If Worksheets("Long Term Ticket").Range("D2").Value = "" Then
MsgBox "Please enter ticker in Range D2 and re-run macro."
GoTo ender:
End If
User = Environ("UserProfile")
file = User & "\" & "My Documents\Trade Tickets\Long Term Ticket " &
Worksheets("Long Term Ticket").Range("D2").Value
Workbooks.Open file
Dim wbk As Workbook
wbk = ActiveWorkbook
twbk.Sheets("Long Term Ticket").Range("e4:e14") = wbk.Sheets("Long Term
Ticket").Range("e4:e14")
twbk.Sheets("Long Term Ticket").Range("D2022") = wbk.Sheets("Long Term
Ticket").Range("D2022")
twbk.Sheets("Long Term Ticket").Range("D2837") = wbk.Sheets("Long Term
Ticket").Range("D2837")
twbk.Sheets("Long Term Ticket").Range("D4050") = wbk.Sheets("Long Term
Ticket").Range("D4050")
twbk.Sheets("Long Term Ticket").Range("h4:h50") = wbk.Sheets("Long Term
Ticket").Range("h4:h50")
wbk.Close savechanges:=False
ender:
Range("A2").Select
End Sub