+ Reply to Thread
Results 1 to 6 of 6

Changing the Caption of an Option button in a userform using vba

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Changing the Caption of an Option button in a userform using vba

    Hi there

    I don't know if this is possible, but can the caption of an option button be changed using vba?

    I have 4 Option buttons, namely opt1, opt2, opt3 and optOther. In a named range, I have a list of hierarchical names such as:

    David Sykes, Andrea Brown, Carl Davids, Petra Jones, Steven Prentice and Belinda Grant in that order.

    When I open the userform, I would like to see the option button opt1 showing the caption "David Sykes", opt2 showing "Andrea Brown", opt3 showing "Carl Davids". optOther will keep the caption "Other", but underneath it is a combobox cboOther, which when the user clicks the "Other" option, populates the combobox with the remaining list of names not shown on the option buttons (in this example, it would show Steven Prentice and Belinda Grant. (btw all names are ficticious!)

    Finally, I want to extract the initials of the names selected, so if Carl Davids is selected, it will return cd.

    mmm... I suspect this is not possible, but any advice will be greatly appreciated!

    Many thanks

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Changing the Caption of an Option button in a userform using vba

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Changing the Caption of an Option button in a userform using vba

    And this wil do the initials

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Changing the Caption of an Option button in a userform using vba

    Hello Andy

    The first worked a treat. I really didn't think there was a way! Thanks for that.

    Unfortunately the getting initials code threw up an error highlighting "m_GetInitials" and specifing error message "Sub or Function not defined"

    What do you think could be the problem?

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Changing the Caption of an Option button in a userform using vba

    Sorry forgot to post the function. Add this to the userform code module.

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Changing the Caption of an Option button in a userform using vba

    Sorry about the delayed response, Andy.

    Works perfectly now! Very grateful for your help.

    Cheers

+ 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