Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Advanced Excel 2007 VBA Question...?
I have created a series of spreadhseets for use in our office. I would like to create a seperate spreadsheet that can open these spreadsheets and activate the procedures built in them. I can't seem to find the code needed to call a Sub or Function procedure from another workbook. Is there anyone out there that knows how this can be done?
3 Answers
- Michael GLv 51 decade agoFavorite Answer
If I read your question clearly, you are only asking how to call a macro from within another macro?
If so it is simple.... we will call macro2() while using macro1()
Sub macro1()
Application.Screenupdating = False
Call macro2
The application.screenupdating = false , of course I assume you know stops the flicker on screen.
If you want to set a variable. Try something like this
Sub macro1()
If Sheets("1").cells(1, 1) = Sheets("2").cells(5, 4) then call macro2
So if sheet 1 cell A1 is = sheet 2 cell D5 then macro2 is called.
____________________________
or my favorite is something like
Sub macro1()
Call macro2
msg = msgbox ("Do you wish to call macro2?", vbYesNo)
If vbNo then exit sub
- 1 decade ago
Take a look at the workbooks class. You should be able to point to any file and then open and use it from your main spreadsheet.
*********************************
Sorry, should have read your post more closely. Have you tried ExecuteExcel4Macro? You have to activate the sheet first. There is also the Run method within the application class.
- There you are∫Lv 61 decade ago
want to know what the code is?
Using macro record- record yourself opening it manually.
Viola! now you have code!!!
I have speadsheets that trigger other spreadsheets that trigger still another spreadsheet.
Like dominos.
cut and paste that from the macro record into your VBA- it's the very same thing after all.....