+ Reply to Thread
Results 1 to 6 of 6

Find Userform controls based on Control Name

  1. #1
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Find Userform controls based on Control Name

    Hi,

    I am trying to find userform control based on their name (exp: txtInput01 [Textbox], cboInput01 [combobox])

    Like Userform1.contorls.name = txtInput01 then do something.

    Thanks,
    KC

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Find Userform controls based on Control Name

    Please Login or Register  to view this content.
    Last edited by humdingaling; 06-29-2017 at 09:57 PM. Reason: formatting
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Find Userform controls based on Control Name

    Hi humdingaling,

    Thanks for your feedback. I incorporate the code into my project and modify accordingly to suit my need.
    Do you think the code below can further optimize it?

    Description on code below:

    I have 2 userform (U1 and U2). Both of them are having same controls and same name as well (exp. U1.txtInput01 and U2.txtInput02)
    Each of the userform have approximate 50 controls (label and frame) and all are having same Control Name
    so code below will help me to emulate U1 content and setting to U2 form

    Please Login or Register  to view this content.
    Thanks,
    KC

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Find Userform controls based on Control Name

    not every control has the same things you can change
    ie textbox doesnt have caption it has text instead
    so what do you want to do then>

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Find Userform controls based on Control Name

    Please Login or Register  to view this content.
    also changes made in code arent generally permanently saved...only in the running of the code
    ie if you set textbox1.text = "Test" from "blank" in the code...when the code finishes it returns to "blank"

  6. #6
    Registered User
    Join Date
    11-27-2012
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    66

    Re: Find Userform controls based on Control Name

    Hi humdingaling,

    Your idea was great. It help my code's length reduce by ~60%.

    Thanks,
    KC

+ 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. Loop through Userform Controls and assign value control to cell
    By peejayjay in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2017, 01:56 PM
  2. [SOLVED] adapt userform loop using control name containing variable for worksheet activex controls
    By bmeister in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-22-2014, 02:45 PM
  3. [SOLVED] How to reference Controls in a Userform based on the control's tabindex instead of name?
    By bmxfreedom in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 11-05-2013, 02:27 PM
  4. Replies: 5
    Last Post: 02-27-2013, 12:04 PM
  5. Replies: 1
    Last Post: 10-12-2012, 04:36 AM
  6. Userform - Picture inserted into image1 control based on what is populated into t
    By johncembree in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2010, 03:44 AM
  7. Code to format number input in textbox controls (based on tag) in userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-05-2010, 01:09 PM

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