Not being used to working with Listboxes, I've been given a code that populates a UserForms Listbox with all the names in column B.
Depending on the selection made, it populates a marker cell at column "U" in the same row with a "1", to work with sheet Formulas.
Unfortunately it only runs once one before closing the UserForm.
What I'm looking for is a modification of my existing code that allows me to make another selection for the second name.
I don't want to make two selections at the same time, but to re-show the list deselected, enabling me to select again from the same list.
Without creating another UserForm I would also like to change the Background colour and Text in a TextBox1 on the UserForm to distinguish between the two options and re-run the code to fill the marker cell.
Existing Code:
Any help to a Newbie appreciated.
Depending on the selection made, it populates a marker cell at column "U" in the same row with a "1", to work with sheet Formulas.
Unfortunately it only runs once one before closing the UserForm.
What I'm looking for is a modification of my existing code that allows me to make another selection for the second name.
I don't want to make two selections at the same time, but to re-show the list deselected, enabling me to select again from the same list.
Without creating another UserForm I would also like to change the Background colour and Text in a TextBox1 on the UserForm to distinguish between the two options and re-run the code to fill the marker cell.
Existing Code:
Code:
Private Sub UserForm_Initialize()
With ActiveSheet.Range("B10")
ListBox1.List = .Resize(.CurrentRegion.Rows.Count, 1).Value
End With
End Sub
Private Sub CommandButton1_Click()
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) Then
lngRow = i + 10
Application.ScreenUpdating = False
End If
Next i
' Enter Formula Marker in column U
On Error GoTo NOPICK
Range("U" & lngRow).Value = "1"
Application.ScreenUpdating = True
#######
Need to add 2nd choice option here with change of BackColor & Text.
' Change Background Colour & Text
BackColor = &HFFC0C0
TextBox1.Value = "Second Choice"
#######
Unload Me
Range("D6").Select
MsgBox "Finished", 64, "All Done"
Exit Sub
NOPICK:
MsgBox " No selection made.", 64, "Error"
End Sub
Any help to a Newbie appreciated.