+ Reply to Thread
Results 1 to 6 of 6

run macro from workbook A to perform on workbook B

  1. #1
    Registered User
    Join Date
    09-08-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 SP3
    Posts
    45

    Question run macro from workbook A to perform on workbook B

    Hi there,

    I currently have 2 workbooks. Workbook A contains the macro that I have created. Workbook B is a workbook that has been given to me by a work colleague that I dont want to modify or add any modules to.

    Basically my macro is functioning, but I when I call it I dont want it to operate on Workbook A I want it to operate on a particular sheet in Workbook B.

    I seen from a lot of posts on the net that the following code
    Please Login or Register  to view this content.
    seems to be able to do this but I believe from what I have seen, you have to add this to Workbook B in my case, and I dont want to do this as I want to keep the original workbook intact.

    Is there a way to do this? If you need the workbooks I am working on I can provide them upon request but Im sure the syntax isn't too demanding - I hope!

    cheers for any help,

    Jag

  2. #2
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: run macro from workbook A to perform on workbook B

    hi Jag,

    Yes, this can be done & probably without the use of "application.run", it all depends on how you define your sheet/range to be acted on.

    I suspect that your code may currently be referencing the "activesheet". If so, this needs to be changed to a more explicit reference for example something like
    Please Login or Register  to view this content.
    .
    Can you please post your existing code?

    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  3. #3
    Registered User
    Join Date
    09-08-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 SP3
    Posts
    45

    Re: run macro from workbook A to perform on workbook B

    Hi there, yeah well I've tried the code below, but it still only seems to work on the current workbook, or workbook A in my example:

    Please Login or Register  to view this content.
    Jag

  4. #4
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: run macro from workbook A to perform on workbook B

    hi Jag,

    This may work...
    If not, can you please provide more detail eg where does the code error?) & perhaps even upload 2 example workbooks?

    Please Login or Register  to view this content.
    hth
    Rob

  5. #5
    Registered User
    Join Date
    09-08-2009
    Location
    Glasgow
    MS-Off Ver
    Excel 2003 SP3
    Posts
    45

    Re: run macro from workbook A to perform on workbook B

    Hi there,

    I've tried the above method within my workbooks but I still cant seem to get it working. All it seems to do is just add another new sheet onto the target workbook but doesnt do anything else.

    Does anyone know what I am doing wrong with the following code:

    Please Login or Register  to view this content.
    Cheers,

    Jag

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: run macro from workbook A to perform on workbook B

    hi Jag,

    I may not be near a computer for the next few days so hopefully somone else can help you...
    Can you please upload a sample file with the actual layout, some hyperlinks & your latest version of the macros?

    Does anyone know what I am doing wrong with the following code:...
    The code you've posted in post 5 is seems to have grown from your original code. It would be helpful if you could tell us where/if it errors. Also can you please explain in normal sentences, what your intent of the below lines of code?
    Please Login or Register  to view this content.
    To try & track down the error, can you please retry my post 4' code with the below section replacing the similar code that's listed in post 4?
    Please Login or Register  to view this content.
    hth
    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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