+ Reply to Thread
Results 1 to 6 of 6

Macro to change optionbutton properties permanently

  1. #1
    Registered User
    Join Date
    07-17-2013
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    14

    Macro to change optionbutton properties permanently

    Hello guys!

    I have a userform with a certain number of options from which the user has to choose one. However, he can also add more, so I created more optionbuttons with no caption and set their visibility to False. If the user wants to add a new option button, he clicks a button that opens a text box where he writes the name of the new optionbutton and, with the following code, the option button appears with the new name.
    novo_desenho.OptionButton54.Visible = True
    novo_desenho.OptionButton54.Caption = TextBox1.value

    The problem is that when I close the userform, the Option Button hides again and has no name saved. I can make it work by doing this the following:
    If Not IsEmpty(ActiveSheet.cell("P5")) Then
    'novo_desenho.OptionButton54.Visible = True
    'novo_desenho.OptionButton54.Caption = TextBox1.value
    'End If

    ...but it's not efficient to make excel test this condition for 10 or 20 cells. Isn't there a way to make it save the changes permanently??

    Thanks,
    Hugo

  2. #2
    Forum Contributor
    Join Date
    01-17-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    211

    Re: Macro to change optionbutton properties permanently

    you need some vba code to write vba code , this will set you on the right path.
    http://pubs.logicalexpressions.com/P...cle.asp?ID=307
    If solved remember to mark Thread as solved , to mark your thread as Solved select Thread Tools and click Mark thread as Solved.

    I can't read the mind of my wife so then I get picture but no sound .... and then I mostly get the idea, same goes here picture your outcome and I get the idea.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Macro to change optionbutton properties permanently

    The method you are using and have dismissed as "inefficient" is actually the best option, you could improve the performance of it a little but there's barely any point for only 10 cells. Going down the code with code route is fundamentally the wrong thing to do, it's hacky, messy and requires all users of your workbook to lower their security settings.

  4. #4
    Registered User
    Join Date
    07-17-2013
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Macro to change optionbutton properties permanently

    OK, I'll stick with my first option then! I've also read that code to write code isn't advised, but i'll give it a look because it might be more useful someday.
    Thank you both for your answers!

  5. #5
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Macro to change optionbutton properties permanently

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  6. #6
    Registered User
    Join Date
    07-17-2013
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: Macro to change optionbutton properties permanently

    The reputation star I had already done, I'll keep in mind to mark as solved next time! thanks

+ 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. How to change OptionButton 'BackColor' using Macro
    By rmtschanz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-14-2009, 05:49 AM
  2. Can you change form button properties with a macro?
    By randyvann in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2008, 11:06 AM
  3. Macro to change text properties
    By Josiah in forum Excel General
    Replies: 6
    Last Post: 04-01-2008, 02:13 PM
  4. OptionButton Properties Descriptions ?
    By dpenny in forum Excel General
    Replies: 2
    Last Post: 04-16-2007, 08:18 PM
  5. Replies: 2
    Last Post: 01-19-2006, 09:25 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