Hiding rows macro

biglb79

Active Member
Joined
Oct 17, 2007
Messages
299
is there a macro I can run that would hide any rows 2-200 if the amounts in columns F or G are zero?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi!

Modify it if needed:

Code:
Sub macro()


Dim i As Integer
Dim row As Long


row = Cells(Rows.Count, 1).End(xlUp).row


For i = 1 To row Step 1 'count rows in column "A"




    If Cells(i, "G").Value = 0 Then
     Rows(i).EntireRow.Hidden = True


    End If
    
    If Cells(i, "F").Value = 0 Then
     Rows(i).EntireRow.Hidden = True


    End If
    
    Next
    


    End Sub


is there a macro I can run that would hide any rows 2-200 if the amounts in columns F or G are zero?
 
Upvote 0
thanks, but a majority of the rows will have a value in columns F or G. I just want the rows that have zeros in both columns to hide
 
Upvote 0
You used "or" so don't be surprised at my code :D Next time if you use "and" i will understand what you want.

Try:


Code:
Sub macro()
 
 
Dim i As Integer
Dim row As Long
 
 
row = Cells(Rows.Count, 1).End(xlUp).row
 
 
For i = 1 To row Step 1 'count rows in column "A"
 
 
 
 
    If Cells(i, "G").Value = 0 and Cells(i, "F").Value = 0 Then
     Rows(i).EntireRow.Hidden = True
 
 
    End If
   
    Next
   
 
 
    End Sub
thanks, but a majority of the rows will have a value in columns F or G. I just want the rows that have zeros in both columns to hide
 
Upvote 0
sorry that's my bad. I do really appreciate your help. I didn't realize I worded it incorrectly until I used your code and figured out what was going on
 
Upvote 0
it does work great but for some reason the rows 63, 117 and 118 didn't hide. I wonder if it's a rounding issue
 
Upvote 0

Forum statistics

Threads
1,216,471
Messages
6,130,822
Members
449,595
Latest member
jhester2010

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