+ Reply to Thread
Results 1 to 14 of 14

Passing activecell value to Inputbox of another workbook and run macro there

  1. #1
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Passing activecell value to Inputbox of another workbook and run macro there

    I want to be able to select a cell in my active workbook, click a button to open another workbook in the same directory, and then pass the cell value to the input box of the macro in the other workbook and run the macro with that input value....

    so far, I've got this:

    Please Login or Register  to view this content.
    The macro I want to run is call NewProject on the other workbook.

    I get error that it cannot find "\ProjectCosts.xls!NewProject", Proj (I also tried without the \ at front)

  2. #2
    Valued Forum Contributor blane245's Avatar
    Join Date
    02-20-2009
    Location
    Melbourne, FL
    MS-Off Ver
    Excel 2010
    Posts
    649

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    You are pretty close. Try
    Please Login or Register  to view this content.
    Bob
    Click my star if my answer helped you. Mark the thread as [SOLVED] if it has been.

  3. #3
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Hi Bob,

    I am still getting the exact same error.

    I double and triple checked the workbook name and the macro name.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    What is the code that you want to run? Paste it here using Code Tags
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Hi Roy,

    Here is the code....

    I want to pass the variable from the other workbook to this sub, and automatically insert it into the red Input line below and run the macro with that input....

    Please Login or Register  to view this content.

  6. #6
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    where is the NewProject code located (which module)?
    by the way, this won't work since your NewProject code doesn't use the variable you pass it and it will still popup an inputbox.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  7. #7
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Not sure what you mean by which module.... it is in a main module. i.e. it is not an activex control code nor an worksheet or workbook event...

    Should I be passing ProjectID variable from the original?

    The problem to overcome is still firstly, why isn't it recognizing the module in the first place.

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Quote Originally Posted by JohnnyBGood View Post
    The problem to overcome is still firstly, why isn't it recognizing the module in the first place.
    that's why I asked where the code was. your calling code should be
    Please Login or Register  to view this content.
    if the file and routine names are correct then I reckon maybe there's a module called NewProject too.

  9. #9
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Great, you are right, I also had the Module named NewProject... I didn't know that made a difference.

    But now, as you predicted it is popping up the Input Box, expecting input.... how do I now avoid the input box... or at least have it populated with the variable passed? I did change the Proj variable to ProjectID and it made no difference.

  10. #10
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    check the variable before using the inputbox
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    That's the one!

    Life can be so simple, afterall

    Thanks very much Joseph. That's great

  12. #12
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    One thing cropped up.

    Now, if I try to run the NewProject macro on it's own (ie. directly in the workbook, wanting to use the Inputbox), then I get error

    Please Login or Register  to view this content.
    I guess it is because of the (Optional Proj as String) declaration?

  13. #13
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    no-String is a vba type so shouldn't be the problem. what line do you get highlighted on debug?

  14. #14
    Registered User
    Join Date
    12-20-2005
    Posts
    44

    Re: Passing activecell value to Inputbox of another workbook and run macro there

    Not to worry.. my own stupidity.

    I had changed the Project name as per your prediction, and the button on the sheet was still linked to the old module name... I just edited it and it worked.

    Thanks again for the concern.

+ 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