ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   user form and radio buttons (https://www.excelbanter.com/excel-programming/403866-user-form-radio-buttons.html)

pswanie

user form and radio buttons
 
is there, and what would it look like, a code i can put "behind" my userform
to

1) go check colum a down sheet1 how many names
2)for each name create a radio button

3)for each radio button thats activated go and put those names in cell d24
sheet2

in other words i need it to show all the 10 or 12 names(adding to it
regularly) from column a down on sheet1 and then put the 3 or 4 names that
the user select in cell d24

Dave Peterson

user form and radio buttons
 
I used column A (A1:A###) of sheet1 to get the name.

I didn't use a radio button. Radio buttons are usually used to limit the user
to a single choice. You could use checkboxes so you could choose each name
independently.

But I used a Listbox with a style that looks like it has checkboxes next to it.

My userform had a single listbox and a commandbutton:

Option Explicit
Private Sub CommandButton1_Click()
Dim myStr As String
Dim iCtr As Long
Dim mySep As String

mySep = ", "
myStr = ""
With Me.ListBox1
For iCtr = 0 To .ListCount - 1
If .Selected(iCtr) = True Then
myStr = myStr & ", " & .List(iCtr)
End If
Next iCtr
End With

If myStr = "" Then
'nothing checked
Else
myStr = Mid(myStr, Len(mySep) + 1)
End If

Worksheets("sheet1").Range("d24").Value = myStr

End Sub
Private Sub UserForm_Initialize()
Dim myRng As Range
With Worksheets("sheet1")
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
.ListStyle = fmListStyleOption
.List = myRng.Value
End With
End Sub


pswanie wrote:

is there, and what would it look like, a code i can put "behind" my userform
to

1) go check colum a down sheet1 how many names
2)for each name create a radio button

3)for each radio button thats activated go and put those names in cell d24
sheet2

in other words i need it to show all the 10 or 12 names(adding to it
regularly) from column a down on sheet1 and then put the 3 or 4 names that
the user select in cell d24


--

Dave Peterson


All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com