Consulting

Results 1 to 6 of 6

Thread: Calling a macro from another macro

  1. #1
    VBAX Regular
    Joined
    Jul 2004
    Location
    Cambridge, England
    Posts
    23
    Location

    Calling a macro from another macro

    Not a question, just sharing an experience. It'll highlight the extent to which I'm struggling with the whole "object" concept, at the same time if someone searches for the same thing it might help, so what the hey(?)

    So I had a UserForm with a text box and a command button on. But I wanted to store the actual button code in a separate module, for the sake of organisation (my UserForm mod is 3 feet long already!).

    So I had something like

    Private Sub CommandButton1_Click()
    Macro1
    End Sub
    Macro1 said something like

    Range("Sheet1!A1") = TextBox1
    It took me about 10 minutes to figure that I had to say

    Range("Sheet1!A1") = UserForm1.TextBox1
    I guess the irony is that I covered the object concept for the worksheet (Sheet1!A1), then completely overlooked it for the form.

    HTH someone, sometime.

    Rgds,
    Andy

  2. #2
    VBAX Tutor jamescol's Avatar
    Joined
    May 2004
    Location
    Charlotte, NC
    Posts
    251
    Location
    Andy,
    Thing is - you'll never make that same mistake again! I always learn better when I struggle to figure out something like that.

    James
    "All that's necessary for evil to triumph is for good men to do nothing."

  3. #3
    VBAX Regular Smitty's Avatar
    Joined
    Jun 2004
    Location
    Boulder Creek, CA
    Posts
    30
    Location
    The struggle is what makes us all learn!

    I'll bet we're all gonna benefit from the VBA Certification project! (Thanks Anne!)

    Smitty

  4. #4
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    Quote Originally Posted by Smitty
    The struggle is what makes us all learn!

    In the great words of Joe Was .... Try and try again, the way of the Coder!!

  5. #5
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    Andy,
    Reminds me of the time I had to reference a checkbox on a Userform, it took me about 1/2 hour to figure out how to do it. So don't feel bad about 10 minutes. The worst, is once you figure it out, your kicking yourself cause it's so obvious.
    The most difficult errors to resolve are the one's you know you didn't make.


  6. #6
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Location, Location, Location. Now where was I?

    OOP is another way to say oops.

Posting Permissions

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