Checking a range
Posted by M Walker on August 08, 2001 1:47 AM
Hi,
I'm having a little trouble. I've been given a code that should enable me to check a range of cells for a value below 5. What i would like to happen is if a cell is below this value to be added to a listbox on a user form. The values represent number of stock so i would like both the number of stock left and the stock description. I'm using excel 97.
The problem i'm having is that it dosen't work, simple as that but i don't know why or how to fix it.
Here is the code i'm using...
Dim Stocklevels As Range
Set Stocklevels = Sheets("Totals").Range("a4:a336")
Dim cell As Range
Dim comparerange As Range
ListBox1.Clear
For Each cell In Stocklevels
If cell < 5 Then
ListBox1.AddItem (cell)
End If
Next
End Sub
Any help would be very much appreciated.
Thanks,
Matt