Results 1 to 10 of 10
  1. #1
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts

    Radio buttons on a form

    I've had lots of help here to get some VBA to process EXIF information from my photos (both digital and scans I've added the data to). I have some input boxes to enter data, but want to have an input box with radio buttons so I can select from a list of items. Googling hasn't come up with much, so I wonder if it's possible. Can someone point me in the right direction. Excel 2013 is what I'm using.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    You'll need a userform. Then you can either use option buttons or use a combo or listbox.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    Thanks Rory, I'm beginning to see the light. Next question is, can I have a combo box with teh data pulled from another sheet. e.g.

    'Fill DinnerComboBox
    With DinnerComboBox
    .AddItem "Italian"
    .AddItem "Chinese"
    .AddItem "Frites and Meat"
    End With

    would have the items in teh VBA, but could they be from a sheet, perhaps like this:

    'Fill DinnerComboBox
    With DinnerComboBox
    .AddItem sheet2.Cells(1, 2).value
    .AddItem sheet2.Cells(1, 3).value
    .AddItem sheet2.Cells(1, 4).value
    End With

    This is all stuff I've never done, even in Access where most of my VBA programming was done.

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Yes - you can use the List property to assign a whole range at once, which is much faster and better than using AddItem:

    Code:
    DinnerComboBox.List = Sheets("Some sheet").Range("A1:A100").Value
    for example.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. The Following User Says Thank You to rory For This Useful Post:

    access-mdb (2015-09-21)

  6. #5
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    I'll give that a whirl then! But it may be a while before I can whirl it though...

  7. #6
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    Just been doing a bit of investigating. Perhaps I should have been a bit clearer. I searched for Excel userforms, but what came up was a button to start and process a userform. But my VBA script reads data from a file, and what my script is doing is just asking me to enter some info which isn't in that file. The file holds all the metadata from my photos and isn't a flat file (each photo may have a variable number of fields in it). So I want a userform that's called by the script - is this possible? If it is then I can investigate futher, but if not, then I won't waste my (or anybody else's) time

  8. #7
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Yes - a userform can be loaded by any routine.
    Regards,
    Rory

    Microsoft MVP - Excel

  9. #8
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    OK ta

  10. #9
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,631
    Thanks
    115
    Thanked 645 Times in 589 Posts
    Access,

    One of the neat things to do is use a List box instead of a combobox. Set its ListStyle property to 1- fnListStyleOption and the MultiSelect property to 1-fmMultiSelectMulti. Here is some sample code to load it:

    In the form Module
    Code:
    Private Sub UserForm_Initialize()
    ListBox1.List = Sheets("sheet1").Range("A2:A8").Value
    End Sub
    This will allow you to make multiple selections by ticking the checkboxes. If the list is longer than the listbox, it will have a vertical scrollbar.

    HTH,
    Maud

    Multicheckbox.png Multicheckbox2.png

  11. #10
    WS Lounge VIP access-mdb's Avatar
    Join Date
    Dec 2009
    Location
    Oxfordshire, UK
    Posts
    1,721
    Thanks
    146
    Thanked 156 Times in 149 Posts
    Thanks Maud, but in my application it's to select just one from a number of options, so a radio box or combo box is what I want. But if I find a need for multiple selections I know what to do now!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •