Consulting

Results 1 to 4 of 4

Thread: Can a command button pass variables to a program?

  1. #1
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location

    Can a command button pass variables to a program?

    Hi, All,

    I have a program that I want my users to start/invoke by pressing a command button on the Excel worksheet. Actually, there will be two such buttons and the two programs are slight variations of each other.

    Can I have the command button pass in variable values so I only need to use and maintain one "master" program? The program, using those variables and conditional logic, will then perform the selected processes.

    Or, do I need to build a couple of small "pre-programs" to create and set the variables and their values before passing them to the "master" program?

    Or, is there a better way to do this?

    And, will this work on XL2004 on my Mac (in addition to on my PC)?

    Thanks,
    Ron
    Windermere, FL

  2. #2
    VBAX Regular Chabu's Avatar
    Joined
    Dec 2010
    Location
    Brussels
    Posts
    85
    Location
    I would provide an input/control sheet to the user (or a form if you want) that allows your user to input/select the values that drive your master program.

  3. #3
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    I just (re)discovered something pretty cool.

    If you have a macro that takes an argument, like
    [VBA]Sub Test(aNum As Double)
    MsgBox aNum + 1
    End Sub[/VBA]
    You can call it, and pass an argument to it, from the Macro dialog box.

    Invoke the Macros dialog. (you won't see Test in the list of macros)
    Type 'Test 12' (including the apostrophes) into the Macro Name text box
    A MsgBox with 13 will appear.

    Similarly, you can assign a (forms) button to the macro 'Test 4'.
    Pressing the button will cause a MsgBox to show 5.

    You can pass arguments to a sub with a button, but only a "hard coded" argument.

  4. #4
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Chabu,

    Thanks, I'll look at that possibility. The critical point to any solution is that it run on XL 2004 on our Macs.

    Mik,

    Thanks, that may be what I need; the variable would be a fixed value for each user. At the moment, I'm leaning towards your earlier suggestion of using the button_click event.

    Thanks,
    Ron
    Windermere, FL

Posting Permissions

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