Hiding and unhiding Rows with value less thAN 1

Status
Not open for further replies.

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,966
Office Version
  1. 2019
Platform
  1. Windows
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]
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,311
Office Version
  1. 365
Platform
  1. Windows
Please do not start a new thread. Simply continue on in the original.
 
Status
Not open for further replies.

Forum statistics

Threads
1,136,619
Messages
5,676,847
Members
419,655
Latest member
pd2021vb

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
Top