LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default open file and update data?

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("D20:D22") = wbk.Sheets("Long Term
Ticket").Range("D20:D22")

twbk.Sheets("Long Term Ticket").Range("D28:D37") = wbk.Sheets("Long Term
Ticket").Range("D28:D37")

twbk.Sheets("Long Term Ticket").Range("D40:D50") = wbk.Sheets("Long Term
Ticket").Range("D40:D50")
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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
why do I have to have the source file open to update a database fu TAD from DBL Excel Worksheet Functions 0 October 6th 08 07:30 PM
** Links don't update UNLESS source file is open Jack Links and Linking in Excel 1 July 27th 05 02:02 PM
** Links don't update UNLESS source file is open Jack Links and Linking in Excel 0 July 14th 05 05:55 PM
Update Links on file open Mick Southam Excel Programming 9 August 3rd 04 01:18 AM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"