Hiding and unhiding Rows with value less thAN 1

Status
Not open for further replies.

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,581
Office Version
  1. 2021
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Please do not start a new thread. Simply continue on in the original.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,218,899
Messages
6,145,099
Members
450,590
Latest member
Naneng

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