ExcelBanter

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

Michel[_4_]

ComboBox on UserForm
 
Thank You M. Ogilvy for your answer but...

Private Sub Userform_Initialize()
For i = 1 To 6
ComboBox1.AddItem Worksheets("sheet1").Cells(1, i)
Next
End Sub

Your Example return only the value on my cells A1, B2, etc,
I would like appeared
Column A
Column B
Column C
in my ComboBox1
as the UserForm from "Data - Sort... - of Excel

Could I help me?

Thank you very much,

Michel

Tom Ogilvy

ComboBox on UserForm
 
Private Sub Userform_Initialize()
for i = 1 to 6
if isnumeric(Worksheets("Sheet1").Cells(1,i)) then
combobox1.AddItem "Column " & char(64+i)
End if
Next
end sub

--
regards,
Tom Ogilvy


"Michel" wrote in message
m...
Thank You M. Ogilvy for your answer but...

Private Sub Userform_Initialize()
For i = 1 To 6
ComboBox1.AddItem Worksheets("sheet1").Cells(1, i)
Next
End Sub

Your Example return only the value on my cells A1, B2, etc,
I would like appeared
Column A
Column B
Column C
in my ComboBox1
as the UserForm from "Data - Sort... - of Excel

Could I help me?

Thank you very much,

Michel




Dave Peterson[_3_]

ComboBox on UserForm
 
Just a guess, but I'm betting you made a typo in your code (and copied the
correct version in your post).

You posted this:
ComboBox1.AddItem Worksheets("sheet1").Cells(1, i)

But I bet you have this in your code:
ComboBox1.AddItem Worksheets("sheet1").Cells(i, i)



Michel wrote:

Thank You M. Ogilvy for your answer but...

Private Sub Userform_Initialize()
For i = 1 To 6
ComboBox1.AddItem Worksheets("sheet1").Cells(1, i)
Next
End Sub

Your Example return only the value on my cells A1, B2, etc,
I would like appeared
Column A
Column B
Column C
in my ComboBox1
as the UserForm from "Data - Sort... - of Excel

Could I help me?

Thank you very much,

Michel


--

Dave Peterson


Dave Peterson[_3_]

ComboBox on UserForm
 
Ohhhhhhh. I get it.

Tom Ogilvy wrote:

Private Sub Userform_Initialize()
for i = 1 to 6
if isnumeric(Worksheets("Sheet1").Cells(1,i)) then
combobox1.AddItem "Column " & char(64+i)
End if
Next
end sub

--
regards,
Tom Ogilvy

"Michel" wrote in message
m...
Thank You M. Ogilvy for your answer but...

Private Sub Userform_Initialize()
For i = 1 To 6
ComboBox1.AddItem Worksheets("sheet1").Cells(1, i)
Next
End Sub

Your Example return only the value on my cells A1, B2, etc,
I would like appeared
Column A
Column B
Column C
in my ComboBox1
as the UserForm from "Data - Sort... - of Excel

Could I help me?

Thank you very much,

Michel


--

Dave Peterson



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

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