Hiding rows with a macro

herpasymplex10

Board Regular
Joined
May 26, 2005
Messages
224
I've seen other codes here but can't seem to make them work for my specific need.

I would like a macro (or any option really)
that will hide all rows.

I guess the 'catch' is this:

I want this macro to hide the row if all numbers in the row are above 0

(leaving all rows that have numbers below zero)

My sheet has 8 columns - 3 of those columns have the numbers in it
if any of those columns have a number less than zero, the whole row will stay visible
(even if the other two columns have numbers that are above 0)

Help?
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
here is a sample of a worksheet change code, that should be easily modified to work with what you are wanting

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 If Target.Column = 2 Or Target.Column = 3 Then
  LastRow = Range("A" & Rows.Count).End(xlUp).Row
  Sheets(2).Rows.Hidden = True
   For Goods = 1 To LastRow
    If Cells(Goods, 2) > 0 Or Cells(Goods, 3) > 0 Then _
     Sheets(2).Rows(Goods).Hidden = False
   Next
 End If
End Sub




</PRE>
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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