Add Sheets to ComboBox

Solved/Closed
smuneeb Posts 77 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 - Nov 21, 2015 at 09:30 AM
smuneeb Posts 77 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 - Nov 24, 2015 at 07:07 AM
Hello,

Hi
I would like to know that how to add sheets (which are exist in active workbook) in ComboBox used in Userform.

Thanks

1 reply

BashirYazbik Posts 58 Registration date Monday November 9, 2015 Status Member Last seen December 6, 2015 14
Nov 22, 2015 at 12:08 AM
Smuneeb,

Let's say we have in column A1 to A5
A1 = 1
A2 = 2
A3 = 3
A4 = 4
A5 = 5

- Right click your combobox and choose "Format Control".
- Click on the "Input Range" field.
- Click cell A1 and drag all the way to A5.

That's it. Click on the combobox and you have all the values in it.
1
smuneeb Posts 77 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 1
Nov 22, 2015 at 08:11 AM
Hi
this is ok but I have requested that ComboBox shows no of sheets which is existed in workbook. Please do it in UserForm.
Thanks
0
Rayh > smuneeb Posts 77 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017
Nov 22, 2015 at 04:19 PM
Either of these should do what you need.

Private Sub UserForm_Initialize()
ComboBox1.List = Array("Red", "Green", "Yellow", "Blue")
End Sub

Private Sub UserForm_Initialize()
With ComboBox1
    .Clear
    .AddItem "Red"
    .AddItem "Green"
    .AddItem "Yellow"
    .AddItem "Blue"
End With
End Sub


Private Sub UserForm_Initialize()
With ComboBox1
    .Clear
    .AddItem "Red"
    .AddItem "Green"
    .AddItem "Yellow"
    .AddItem "Blue"
End With
End Sub
0
Or this???
Private Sub userform_Initialize()
ComboBox1.Clear

For n = 1 To Worksheets.Count
    ComboBox1.AddItem Worksheets(n).Name
Next n

End Sub

0
smuneeb Posts 77 Registration date Saturday September 5, 2015 Status Member Last seen March 8, 2017 1
Nov 24, 2015 at 07:07 AM
Hi
Great RayH
How could I Thank You
Marvelous Job
0