+ Reply to Thread
Results 1 to 5 of 5

Call Procedure

  1. #1
    Ronbo
    Guest

    Call Procedure

    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.

  2. #2
    Tom Ogilvy
    Guest

    Re: Call Procedure

    With ThisWorkbook.Worksheets("Sheet1")
    Application.Run "'" & .Range("a1").Value & "'!MySub"
    End with
    --
    Regards,
    Tom Ogilvy

    "Ronbo" <[email protected]> wrote in message
    news:[email protected]...
    > 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.




  3. #3
    Ronbo
    Guest

    Re: Call Procedure

    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




    "Tom Ogilvy" wrote:

    > With ThisWorkbook.Worksheets("Sheet1")
    > Application.Run "'" & .Range("a1").Value & "'!MySub"
    > End with
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Ronbo" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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.

    >
    >
    >


  4. #4
    Tom Ogilvy
    Guest

    Re: Call Procedure

    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.


    --
    Regards,
    Tom Ogilvy


    "Ronbo" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >
    >
    >
    >
    > "Tom Ogilvy" wrote:
    >
    > > With ThisWorkbook.Worksheets("Sheet1")
    > > Application.Run "'" & .Range("a1").Value & "'!MySub"
    > > End with
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > > "Ronbo" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > 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.

    > >
    > >
    > >




  5. #5
    Ronbo
    Guest

    Re: Call Procedure

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

    Thanks alot for you help.

    Regards,
    Ronbo

    "Tom Ogilvy" wrote:

    > 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.
    >
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Ronbo" <[email protected]> wrote in message
    > news:[email protected]...
    > > 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
    > >
    > >
    > >
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > With ThisWorkbook.Worksheets("Sheet1")
    > > > Application.Run "'" & .Range("a1").Value & "'!MySub"
    > > > End with
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > > "Ronbo" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > 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.
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1