I need to set up VBA code in Excel to hide rows where the value is less than 1. For eg if the code is 0.27 i.e less than 1, then the row must hidden.
If the value is >= 1, then the row must be unhidden
it appears that the following code is not working
If c.Value <=1 Then
Nissan UNITS SOLD DOBLO 0.27
Nissan UNITS SOLD 1400 LDV 9.09
Nissan UNIT SLD TERR/XTRAIL 1.82
Nissan UNITS SOLD 1 TON/NAV 14.36
Nissan U/SLD NISS MICRA 1.00
Nissan UNITS SOLD ALM/TIIDA 1.00
Nissan UNIT SLD PATROL/PATH 3.00
Nissan UNITS SLD NIS CSTAR 0.36
Nissan UNITS RET STRADA 9.36
Nissan RET UNITS SOLD STILO 0.09
Nissan U/S FIAT PAL/PUNTO 4.00
Nissan UNITS RT PUNTO/PANDA 4.18
The code below hides all the rows.
Private Sub Worksheet_Activate()
Dim rng As Range, c As Range
Set rng = Columns(3).SpecialCells(xlCellTypeFormulas, 1)
Application.ScreenUpdating = False
For Each c In rng
If c.Value <=1 Then (This code not working)
Rows(c.Row).Hidden = True
Else
Rows(c.Row).Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
Your assistance will be most appreciated
Howard
[/b]
If the value is >= 1, then the row must be unhidden
it appears that the following code is not working
If c.Value <=1 Then
Nissan UNITS SOLD DOBLO 0.27
Nissan UNITS SOLD 1400 LDV 9.09
Nissan UNIT SLD TERR/XTRAIL 1.82
Nissan UNITS SOLD 1 TON/NAV 14.36
Nissan U/SLD NISS MICRA 1.00
Nissan UNITS SOLD ALM/TIIDA 1.00
Nissan UNIT SLD PATROL/PATH 3.00
Nissan UNITS SLD NIS CSTAR 0.36
Nissan UNITS RET STRADA 9.36
Nissan RET UNITS SOLD STILO 0.09
Nissan U/S FIAT PAL/PUNTO 4.00
Nissan UNITS RT PUNTO/PANDA 4.18
The code below hides all the rows.
Private Sub Worksheet_Activate()
Dim rng As Range, c As Range
Set rng = Columns(3).SpecialCells(xlCellTypeFormulas, 1)
Application.ScreenUpdating = False
For Each c In rng
If c.Value <=1 Then (This code not working)
Rows(c.Row).Hidden = True
Else
Rows(c.Row).Hidden = False
End If
Next c
Application.ScreenUpdating = True
End Sub
Your assistance will be most appreciated
Howard
[/b]