ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox on UserForm (https://www.excelbanter.com/excel-programming/305634-combobox-userform.html)

Michel[_4_]

ComboBox on UserForm
 
Hi,

In my UserForm, I have a ComboBox and if in my sheet, sheet1, in my
cells A1 until F1, I have a number, I want to see appeared in my
comboBox:
Column A
Column B
....
Column F

Is it possible?

Thank you

Michel

merjet

ComboBox on UserForm
 

In my UserForm, I have a ComboBox and if in my sheet, sheet1, in my
cells A1 until F1, I have a number, I want to see appeared in my
comboBox:
Column A
Column B
...
Column F

Is it possible?


Yes. Put the following code with the UserForm. Change sheet name
if needed.

Private Sub UserForm_Activate()
Dim iCt As Integer
For iCt = 1 To 6
vData = Sheets("Sheet1").Cells(1, iCt)
If Application.IsNumber(vData) = True Then _
ComboBox1.AddItem vData
Next iCt
End Sub

HTH,
Merjet



Tom Ogilvy

ComboBox on UserForm
 
Using additem. You can't bind the data to the combobox using rowsource.

Private Sub Userform_Initialize()
for i = 1 to 6
combobox1.AddItem Worksheets("sheet1").Cells(1,i)
Next
end sub

or
Private Sub Userform_Initialize()
combobox1.List = Application.Transpose( _
Worksheets("sheet1").Range("A1:F1").Value)
End sub


--
Regards,
Tom Ogilvy

"Michel" wrote in message
om...
Hi,

In my UserForm, I have a ComboBox and if in my sheet, sheet1, in my
cells A1 until F1, I have a number, I want to see appeared in my
comboBox:
Column A
Column B
...
Column F

Is it possible?

Thank you

Michel





All times are GMT +1. The time now is 11:12 PM.

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