ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop Edit (https://www.excelbanter.com/excel-programming/283356-loop-edit.html)

Todd Huttenstine[_2_]

Loop Edit
 
The below code looks for values in the specified range and
adds that value to the listbox. What I would like is for
the code to skip over column Z(not add the value to the
list box) even if there is a value in that column in that
row. How would I do this?

Also I want the code to not add a value to the listbox if
it is is equal to "test".

Private Sub UserForm_Initialize()
Dim Rng As Range
With ListBox1
'Or With ComboBox1
.ColumnCount = 1
For Each Rng In Range("A4:AB4").Cells
If Rng.Text < "" Then
.AddItem Rng.Text
End If
Next Rng
End With

End Sub


Thanx,

Todd

Don Guillett[_4_]

Loop Edit
 
try
if rng.column <26 and Rng.Text < ""

--
Don Guillett
SalesAid Software

"Todd Huttenstine" wrote in message
...
The below code looks for values in the specified range and
adds that value to the listbox. What I would like is for
the code to skip over column Z(not add the value to the
list box) even if there is a value in that column in that
row. How would I do this?

Also I want the code to not add a value to the listbox if
it is is equal to "test".

Private Sub UserForm_Initialize()
Dim Rng As Range
With ListBox1
'Or With ComboBox1
.ColumnCount = 1
For Each Rng In Range("A4:AB4").Cells
If Rng.Text < "" Then
.AddItem Rng.Text
End If
Next Rng
End With

End Sub


Thanx,

Todd





All times are GMT +1. The time now is 05:36 PM.

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