+ Reply to Thread
Results 1 to 5 of 5

Userform Call Macro on Control Change

  1. #1
    Registered User
    Join Date
    05-22-2009
    Location
    Shirland, IL
    MS-Off Ver
    Excel '00 & '03
    Posts
    51

    Userform Call Macro on Control Change

    Hey Quick question,

    Is there a way to call a subroutine anytime any control is changed within a userform?

    For example,

    I have a userform that needs to go through and add/multiply almost every value in every textbox and also add together values associated with checkboxs. I need this to happen anytime a textbox value is changed or a checkbox is checked.

    Is there a quick way to do this?

    Thanks,
    Ethan
    Last edited by fire_water; 07-22-2009 at 12:42 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,255

    Re: Userform Call Macro on Control Change

    Hello Ethan,

    Place a call to your macro in the CheckBox_Change() event module and in the TextBox_AfterUpadte() event module of each control.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-22-2009
    Location
    Shirland, IL
    MS-Off Ver
    Excel '00 & '03
    Posts
    51

    Re: Userform Call Macro on Control Change

    Hello Leith,

    I know i can do that, but i have about 60 textboxes on there right now and about 20 or so checkboxes, so i was hoping there might be a way to do an update of the whole thing without having to create so many lines of code.

    If there isn't then it shouldn't take too long to do so.

    Thanks

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,255

    Re: Userform Call Macro on Control Change

    Hello Ethan,

    VBA like Windows, is event driven. In Visual Basic (not VBA) you can create Control Arrays which simplifies this type of operation. Unfortunately, this feature doesn't exist in VBA. There are workarounds to simulate a control array. However, the amount of code needed and the complexity involved outweighs the benefit.

  5. #5
    Registered User
    Join Date
    05-22-2009
    Location
    Shirland, IL
    MS-Off Ver
    Excel '00 & '03
    Posts
    51

    Re: Userform Call Macro on Control Change

    Alright, Well Thanks anyways, I think i'm just going to create a button for the user to click to solve this probelm. Not automated, but simple.

    -Ethan

+ 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