leebrockney
New Member
- Joined
- Feb 19, 2008
- Messages
- 18
I am trying to write a quick VBA macro to hide rows where a specific cell value does not meet a required value. I am easily able to do this using the following code.
Sub OSR_ReportComplete()
Dim cell As Range
For Each cell In Range("DataRange")
If UCase(cell.Value) < 50000 Then
cell.EntireRow.Hidden = True
End If
Next
End Sub
The issue is that this makes me hard code in the criteria (50000). I want to have the person running the macro enter the criteria. I have a cell named "Limit" that the user enters their custom setting. when I reference the cell name like below. it does not work. what am I doing wrong?
Sub OSR_ReportComplete()
Dim cell As Range
For Each cell In Range("DataRange")
If UCase(cell.Value) < Range("Limit").Value Then
cell.EntireRow.Hidden = True
End If
Next
End Sub
Thanks!!
Lee
Sub OSR_ReportComplete()
Dim cell As Range
For Each cell In Range("DataRange")
If UCase(cell.Value) < 50000 Then
cell.EntireRow.Hidden = True
End If
Next
End Sub
The issue is that this makes me hard code in the criteria (50000). I want to have the person running the macro enter the criteria. I have a cell named "Limit" that the user enters their custom setting. when I reference the cell name like below. it does not work. what am I doing wrong?
Sub OSR_ReportComplete()
Dim cell As Range
For Each cell In Range("DataRange")
If UCase(cell.Value) < Range("Limit").Value Then
cell.EntireRow.Hidden = True
End If
Next
End Sub
Thanks!!
Lee