J
jfcby
Hello,
I have a userform with a combo box and a commandbutton. The combobox
uses the .additem, currently it has 11 items but will be added to. My
UserForm_Initialize is below:
Private Sub UserForm_Initialize()
Dim varData(10) As Variant
varData(0) = ""
varData(1) = "Search"
varData(2) = "Find"
varData(3) = "GoTo"
varData(4) = "Compare Data"
varData(5) = "Delete Characters"
varData(6) = "Number Cells 1-25"
varData(7) = "Number Sells Value 001"
varData(8) = "Find Blank Cell"
varData(9) = "Fill Selection Copy"
varData(10) = "Fill Selection Series"
With ComboBox1
.AddItem varData(0)
.AddItem varData(1)
.AddItem varData(2)
.AddItem varData(3)
.AddItem varData(4)
.AddItem varData(5)
.AddItem varData(6)
.AddItem varData(7)
.AddItem varData(8)
.AddItem varData(9)
.AddItem varData(10)
End With
End Sub
My commandbutton is below:
Private Sub CommandButton3_Click()
cb = ComboBox1
If cb = "" Then
'Do Nothing
ElseIf cb = "Search" Then
Call UserFormFIND
ElseIf cb = "Find" Then
Call FindDialogBoxOpen
ElseIf cb = "GoTo" Then
Call GoToDialogBoxOpen
ElseIf cb = "Compare Data" Then
Call CompareData
ElseIf cb = "Delete Charcters" Then
Call DeleteCharcters
ElseIf cb = "Number Cells 1-25" Then
Call NumberCells
ElseIf cb = "Number Cels Value 001" Then
Call NumberCellsValue
ElseIf cb = "Find Blank Cells" Then
Call FindBlankCell
ElseIf cb = "Fill Selection Copy" Then
Call Selection.FillDown
ElseIf cb = "Fill Selection Series" Then
Call FillSelection_Series
End If
End Sub
All of my elseif has the same name as my UserForm_Initialize. How can
I use the UserForm_Initialize varData array in my command button so
that I do not have to type the list twice?
Thank you for your help,
jfcby
I have a userform with a combo box and a commandbutton. The combobox
uses the .additem, currently it has 11 items but will be added to. My
UserForm_Initialize is below:
Private Sub UserForm_Initialize()
Dim varData(10) As Variant
varData(0) = ""
varData(1) = "Search"
varData(2) = "Find"
varData(3) = "GoTo"
varData(4) = "Compare Data"
varData(5) = "Delete Characters"
varData(6) = "Number Cells 1-25"
varData(7) = "Number Sells Value 001"
varData(8) = "Find Blank Cell"
varData(9) = "Fill Selection Copy"
varData(10) = "Fill Selection Series"
With ComboBox1
.AddItem varData(0)
.AddItem varData(1)
.AddItem varData(2)
.AddItem varData(3)
.AddItem varData(4)
.AddItem varData(5)
.AddItem varData(6)
.AddItem varData(7)
.AddItem varData(8)
.AddItem varData(9)
.AddItem varData(10)
End With
End Sub
My commandbutton is below:
Private Sub CommandButton3_Click()
cb = ComboBox1
If cb = "" Then
'Do Nothing
ElseIf cb = "Search" Then
Call UserFormFIND
ElseIf cb = "Find" Then
Call FindDialogBoxOpen
ElseIf cb = "GoTo" Then
Call GoToDialogBoxOpen
ElseIf cb = "Compare Data" Then
Call CompareData
ElseIf cb = "Delete Charcters" Then
Call DeleteCharcters
ElseIf cb = "Number Cells 1-25" Then
Call NumberCells
ElseIf cb = "Number Cels Value 001" Then
Call NumberCellsValue
ElseIf cb = "Find Blank Cells" Then
Call FindBlankCell
ElseIf cb = "Fill Selection Copy" Then
Call Selection.FillDown
ElseIf cb = "Fill Selection Series" Then
Call FillSelection_Series
End If
End Sub
All of my elseif has the same name as my UserForm_Initialize. How can
I use the UserForm_Initialize varData array in my command button so
that I do not have to type the list twice?
Thank you for your help,
jfcby