Call Procedure

G

Guest

In Workbook A I have procedures that execute and then it opens Workbook B. I
now need to run procedures in workbook B.

The name "Workbook B" that Workbook A uses to open Workbook B is in Cell A1.
There are numerous workbooks that Workbook A Opens based on the name in cell
A1.

What I need is a way to call the procudures in the Workbook being opened
based on name in Cell A1.

I have tried...
Application.Run "'(Range("a1").Value)'!MySub"
Call (Range("a1").Value).MyModule.MySub

But can not get it to work.

Any help will be truly appreciated.

Regards,




I need a way of calling the procdures based upon various workbooks.
 
T

Tom Ogilvy

With ThisWorkbook.Worksheets("Sheet1")
Application.Run "'" & .Range("a1").Value & "'!MySub"
End with
 
G

Guest

Thanks alot for your help. However I am stilling doing something wrong. What
I have is the following Sub in Workbook A:

Sub OpenRunReport()
'
Workbooks.Open (Range("a1").Value)

With ThisWorkbook.Worksheets("sheet1")
Application.Run "'" & .Range("a1").Value & "'!MySub"
End With

End Sub

It opens and goes to WorkBook B but it gives me an 1004 Run-time error
(0.953543...xls could not be found). Cell A1 in Workbook A contains the full
path and filename. If I use cell B1 with just the file name it gives me an
error that the macro can not be found.

Any ideas what I am doing wrong?

Thanks,
Ronbo
 
T

Tom Ogilvy

is Sheet1 in WorkbookA the activesheet when you run the macro?

If not, I told it specifically to get the value from Sheet1. Adjust the
sheet name to point to the correct sheet.

If A1 contains Myworkbook.xls

then it should work.

If A1 includes the path and B1 shows MyWorkbook.xls, then use B1.

If you hard code the name and it says it can't find the macro, then make
sure the macro is in a general module, not a sheet module or the
thisworkbook module or a class module.
 
G

Guest

You were exactly right... I was on "sheet2". Changing it "sheet2", it now
works perfect.

Thanks alot for you help.

Regards,
Ronbo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top