+ Reply to Thread
Results 1 to 8 of 8

Application.Run Error When Using A Variable to Run Macro In Another Sheet

  1. #1
    Registered User
    Join Date
    04-26-2013
    Location
    California, USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    4

    Application.Run Error When Using A Variable to Run Macro In Another Sheet

    Hello!

    I am new to VBA and having trouble using a variable to run a macro in another sheet. The macro I'm trying to run is called "bride". It copies a range in a sheet that I want to paste in my active sheet. When I try to run the code below, I get a syntax error for the "Application.Run" command and I haven't been able to figure out what I'm doing wrong after much trial and error! I also tried defining the "copyWB" variable as a workbook, but couldn't get that to work either.

    Thanks for any help!

    Please Login or Register  to view this content.
    Last edited by taylorvba; 04-26-2013 at 06:48 PM.

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

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    Please Login or Register  to view this content.
    because there are spaces in the workbook name
    Josie

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

  3. #3
    Registered User
    Join Date
    04-26-2013
    Location
    California, USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    4

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    Appreciate the reply JosephP!

    Just tried and when I put your syntax in, I get "compile error: Expected: end of statement"

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

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    please copy and paste the exact code you tried

  5. #5
    Registered User
    Join Date
    04-26-2013
    Location
    California, USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    4

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    Looks like I had some spaces around the & missing. Sorry about that. However, now I'm getting this error (I have both workbooks open BTW):

    Run-time error '9':
    Subscript out of range

    Have pasted the latest code below
    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: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    that's still not actually what I posted-no spaces before or after the single quotes

    are you sure your workbook and sheet names are correct?

  7. #7
    Registered User
    Join Date
    04-26-2013
    Location
    California, USA
    MS-Off Ver
    Excel Mac 2011
    Posts
    4

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    That worked! Thanks.

    Also, just for future reference/my learning, would it be better to define the copyWB variable as a Workbook? In this case, how would the code need to look?

    Thanks again.

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

    Re: Application.Run Error When Using A Variable to Run Macro In Another Sheet

    Please Login or Register  to view this content.
    not better just a different approach ;-)

+ 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