Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA routines in different files

Status
Not open for further replies.

speedy12

Mechanical
Joined
Oct 10, 2001
Messages
8
Location
US
I have set up a spreadsheet that contains legacy data used on a daily basis. I have another spreadsheet that is completed for each job and stored. I want to create a routine in the job specific file that will call(start) a routine in the legacy spreadsheet(file). Is this possible and if so how?
Thanks in advance for any help.
 
Create a template from the legacy file and save it in the XLStart directory. Any macros in the template will be available from any open spreadsheet.

See Excel help for specifics.
 
Can add a reference in the job specific file (from VBasic editor) to the open legacy file. Can then easily refer to macros written in the legacy file.
 
Mutt is right... just thought I'd give you a example to help...

Dim rngLegacyBook as Range
Set rngLegacyBook = Workbook("My Legacy Workbook").Worksheets("Sheet1").Range("A1")

After the Set statement is executed, you can refer to the Range object simply as rngLegacyBook.

For example, you can assign a value to A1 in the legacy workbook with:
rngLegacyBook.Value = 10


Have a great day!

Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top