+ Reply to Thread
Results 1 to 4 of 4

How do I call macro depending on which textbox the user fills in?

  1. #1
    Registered User
    Join Date
    09-19-2021
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    15

    How do I call macro depending on which textbox the user fills in?

    I'm trying to write a code where if the user inputs text in TextBox1 only then clicks a command button called Assign, macro1 called SOLVER will be run and if they input text in TextBox2 only then click the same command button called Assign, macro2 called sms will be run but I'm not sure how to do it. Thank you!


    macro1:
    Please Login or Register  to view this content.
    macro2
    Please Login or Register  to view this content.
    Last edited by shuxin; 11-04-2021 at 07:10 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: How do I call macro depending on which textbox the user fills in?

    Are these textboxes in userform, or in the worksheet?

    Basically: in a code associated with the assign button you shall check the conmtent of both textboxes. If the box 2 is <>"" then
    Please Login or Register  to view this content.
    if box 1 is not empty - call solver (by the way, I'd use different name for this procedure, like run_my_solver or something like that, to make it unique )
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    09-19-2021
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    15

    Re: How do I call macro depending on which textbox the user fills in?

    Hello, thank you so much for your reply. My textbox is in the userform, I tried "If Textbox1.Value <> Then" but it says there is an error. May I know if you know how I can fix it? Thank you!

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: How do I call macro depending on which textbox the user fills in?

    File as an attachment probably would be quite useful, byt at first try
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Userform, fill Textbox with calender week (ww) depending on date from another TextBox
    By crowmagnus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-29-2020, 09:24 AM
  2. [SOLVED] List box fills with duplicate values while searching through textbox.
    By thebeastslayer in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2020, 08:03 AM
  3. Replies: 6
    Last Post: 12-31-2019, 05:27 PM
  4. [SOLVED] Call macro depending on cell link of a Form Control Box
    By esbencito in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-27-2017, 05:09 AM
  5. Add Macro to Call Subs Depending on Cell Value
    By John Maier in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2014, 10:45 AM
  6. Need a table, which fills in numbers automatically depending on text in column
    By Hotsoup666 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2013, 03:13 AM
  7. [SOLVED] Userform - ComboBox fills TextBox not working
    By thom hoyle in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2005, 04:05 PM

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