Hiding and unhiding Rows where the value > 0, < 1

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,599
Office Version
  1. 2021
Platform
  1. Windows
I am trying to get the following code to hide rows in Excel where the value in column C is greater than zero, but less than 1. The code " If c.Value <1 Then Rows(c.Row).Hidden = True" does not work

See Sample worksheet below. I need to hide the rows where the values are below 1 for eg 0.36


Nissan UNITS SOLD 1 TON/NAV 14 29.59%
Nissan UNITS RET STRADA 9 19.29%
Nissan UNITS SOLD 1400 LDV 9 18.73%
Nissan UNITS RT PUNTO/PANDA 4 8.61%
Nissan U/S FIAT PAL/PUNTO 4 8.24%
Nissan UNIT SLD PATROL/PATH 3 6.18%
Nissan UNIT SLD TERR/XTRAIL 2 3.75%
Nissan U/SLD NISS MICRA 1 2.06%
Nissan UNITS SOLD ALM/TIIDA 1 2.06%
Nissan UNITS SLD NIS CSTAR 0.36 0.75%
Nissan RET UNITS SOLD STILO 0.09 0.19%


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
        Rows(c.Row).Hidden = True
    Else
        Rows(c.Row).Hidden = False
    End If
Next c
Application.ScreenUpdating = True
End Sub


Your assistwance will be most appreciated

Howard
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
This is what I use for the selected value to hide rows if equal to zero

Code:
 Sub HideZeroRows()
    Application.ScreenUpdating = False 'turn off screen updating

    Selection.EntireRow.Hidden = False
    Set wrkRange = Selection
    For Each rw In wrkRange.Rows
       If Application.Sum(rw) = 0
 Then
            rw.EntireRow.Hidden = True
        End If
    Next
    Application.ScreenUpdating = True 'refresh the screen

End Sub

You can change it to If Application.Sum(rw) < 1
 
Upvote 0
Hi OnlyaDrafter

Thanks for your help

Regards

Howard
 
Upvote 0

Forum statistics

Threads
1,224,351
Messages
6,178,058
Members
452,822
Latest member
MtC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top