ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range for combobox with IF (https://www.excelbanter.com/excel-programming/422979-range-combobox-if.html)

KUMPFfrog

Range for combobox with IF
 
I have a user form with a combobox. I don't know much about writing code,
but i would like the ref list (range) to prettymuch be col B starting at row
7 - however i don't want everything in that col. I just want everything with
a number, no blanks or text.

JLGWhiz

Range for combobox with IF
 
This has not been tested, but should be OK. If not, post back with any error
messages received. Open the VB editor, right click on the userform name and
click view code in the pop up menu. Paste the code below into the code
window for the form. When you use the UserForm1.Show in the standard code
module1, it should load your combo box.

Private Sub UserForm_Initialize()
Dim lr As Long, i As Long
lr = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
For i = 7 To lr
If .Cells(i, 2) < "" And IsNumeric(.Cells(i, 2)) Then
Me.ComboBox1.AddItem .Cells(i, 2)
End If
Next
End With
End Sub




"KUMPFfrog" wrote:

I have a user form with a combobox. I don't know much about writing code,
but i would like the ref list (range) to prettymuch be col B starting at row
7 - however i don't want everything in that col. I just want everything with
a number, no blanks or text.


KUMPFfrog

Range for combobox with IF
 
Great!!! Thanks so much
Now how do I make this numeric list show as assending?

"JLGWhiz" wrote:

This has not been tested, but should be OK. If not, post back with any error
messages received. Open the VB editor, right click on the userform name and
click view code in the pop up menu. Paste the code below into the code
window for the form. When you use the UserForm1.Show in the standard code
module1, it should load your combo box.

Private Sub UserForm_Initialize()
Dim lr As Long, i As Long
lr = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
For i = 7 To lr
If .Cells(i, 2) < "" And IsNumeric(.Cells(i, 2)) Then
Me.ComboBox1.AddItem .Cells(i, 2)
End If
Next
End With
End Sub




"KUMPFfrog" wrote:

I have a user form with a combobox. I don't know much about writing code,
but i would like the ref list (range) to prettymuch be col B starting at row
7 - however i don't want everything in that col. I just want everything with
a number, no blanks or text.


JLGWhiz

Range for combobox with IF
 
See if this site can help you with that:

http://support.microsoft.com/kb/227178





"KUMPFfrog" wrote:

Great!!! Thanks so much
Now how do I make this numeric list show as assending?

"JLGWhiz" wrote:

This has not been tested, but should be OK. If not, post back with any error
messages received. Open the VB editor, right click on the userform name and
click view code in the pop up menu. Paste the code below into the code
window for the form. When you use the UserForm1.Show in the standard code
module1, it should load your combo box.

Private Sub UserForm_Initialize()
Dim lr As Long, i As Long
lr = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
For i = 7 To lr
If .Cells(i, 2) < "" And IsNumeric(.Cells(i, 2)) Then
Me.ComboBox1.AddItem .Cells(i, 2)
End If
Next
End With
End Sub




"KUMPFfrog" wrote:

I have a user form with a combobox. I don't know much about writing code,
but i would like the ref list (range) to prettymuch be col B starting at row
7 - however i don't want everything in that col. I just want everything with
a number, no blanks or text.


KUMPFfrog

Range for combobox with IF
 
JLGWhiz
i was hoping you could help me again. this time i want to populate a
combobox based on this criteria:
column "n" only if coresponding value in column "s" matches textbox.value

"JLGWhiz" wrote:

This has not been tested, but should be OK. If not, post back with any error
messages received. Open the VB editor, right click on the userform name and
click view code in the pop up menu. Paste the code below into the code
window for the form. When you use the UserForm1.Show in the standard code
module1, it should load your combo box.

Private Sub UserForm_Initialize()
Dim lr As Long, i As Long
lr = ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
With ActiveSheet
For i = 7 To lr
If .Cells(i, 2) < "" And IsNumeric(.Cells(i, 2)) Then
Me.ComboBox1.AddItem .Cells(i, 2)
End If
Next
End With
End Sub




"KUMPFfrog" wrote:

I have a user form with a combobox. I don't know much about writing code,
but i would like the ref list (range) to prettymuch be col B starting at row
7 - however i don't want everything in that col. I just want everything with
a number, no blanks or text.



All times are GMT +1. The time now is 09:39 PM.

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