+ Reply to Thread
Results 1 to 9 of 9

Change properites of a group of the buttons on useform

  1. #1
    Forum Contributor
    Join Date
    02-05-2015
    Location
    czech
    MS-Off Ver
    2010
    Posts
    172

    Change properites of a group of the buttons on useform

    Hello dear Excel Help,

    I would like to change properites of a group of the buttons on useform upon condition. I can't figure it out. For example I have userform named 'UserForm1' with buttons named 'but1', 'but2', 'but3', 'dut1', 'dut2'. How woud I change properties of buttons 'but'?

    I tried this Debug.Print UserForm1.Controls(1).name which gives me name of first button, but is seems that no properties can be changed like UserForm1.Controls(1),method.

    I would also like to change properties of multiple Userfrosm and their buttons at once. With following code I can display properties of arbitrary object, but I don't know how to change them.:
    Please Login or Register  to view this content.
    Bellow I provided another function so that you can see my reasoning. I think of all objects in excel as multidimensional matrix and I would like to be able to slice or filter this matrix. Is it possible? I am trying to program this functionality, but without success yet. Maybe I will have to resort to string execute. I am afraid it won't work either.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Change properites of a group of the buttons on useform

    Something Like this:-


    Please Login or Register  to view this content.
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    02-05-2015
    Location
    czech
    MS-Off Ver
    2010
    Posts
    172

    Re: Change properites of a group of the buttons on useform

    Thank you Mehmetcik, but I need reference to the userform in subroutine outside the useform. I can't use 'Me reference.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Change properites of a group of the buttons on useform

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-05-2015
    Location
    czech
    MS-Off Ver
    2010
    Posts
    172

    Re: Change properites of a group of the buttons on useform

    Yes Mehmetcik this would work partially. I would like to access multiple useforms in loops. With Userform1.Controls I have to use UserForm1. For example I have string array named arr of userform names and I would like to use it like this:
    For i=1 To 3
    For j = 1 To 5
    thisworkbook.vbproject.vbcomponents(arr(i)).controls(j).property= some_value
    Next j
    Next i

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change properites of a group of the buttons on useform

    Hi,

    Do you want the changes to be permanent or only applied to the loaded version of the form?

  7. #7
    Forum Contributor
    Join Date
    02-05-2015
    Location
    czech
    MS-Off Ver
    2010
    Posts
    172

    Re: Change properites of a group of the buttons on useform

    Dear xlnitwit, It would be great to have both methods in arsenal.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Change properites of a group of the buttons on useform

    All right then - here is a method for each one.

    For permanent changes:
    Please Login or Register  to view this content.
    and to only change loaded forms:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-05-2015
    Location
    czech
    MS-Off Ver
    2010
    Posts
    172

    Re: Change properites of a group of the buttons on useform

    xlnitwit thank you very much after so much pain it finally works. You are my saviour. Powerful technique indeed.

+ 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. Adding a textbox to a useform upon clicking on a button in the useform.
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2016, 08:16 AM
  2. Option Buttons: Selection in One Group Enables the Next Group
    By excelforumkeys in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-24-2014, 04:00 PM
  3. Replies: 0
    Last Post: 05-28-2013, 04:52 PM
  4. Useform Code - 12 Command Buttons dependant on other command buttons
    By darrenkaye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-20-2013, 10:58 AM
  5. Group Box with Option Buttons
    By e4excel in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 12-01-2009, 02:05 AM
  6. Change option button when useform is cleared
    By Reidm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2008, 07:57 AM
  7. [SOLVED] group option buttons
    By umba-sr in forum Excel General
    Replies: 1
    Last Post: 03-07-2006, 10:10 AM

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