Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

Using VBA routines in different files

Status
Not open for further replies.

speedy12

Mechanical
Oct 10, 2001
8
0
0
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.
 
Replies continue below

Recommended for you

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.
Back
Top