Macro to hide rows if the value is zero in all five columns

harry2908

Board Regular
Joined
May 7, 2010
Messages
87
I am not familiar with VBA, i require a macro which would hide rows if the value is zero in all five columns.

The macro need to see the data only b/w range C4:G65.
If all five cells i.e. C4, D4, E4, F4, G4 are 0 or 0.00 hide those rows.

Please can someone help with a macro....:confused:
Appreciate your help...!!!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Code:
[COLOR="Blue"]Sub[/COLOR] FFF()

    [COLOR="Blue"]Dim[/COLOR] i [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR]
    
    [COLOR="Blue"]For[/COLOR] i = 4 [COLOR="Blue"]To[/COLOR] 65
        [COLOR="Blue"]If[/COLOR] WorksheetFunction.Sum(Range("C" & i & ":G" & i)) = 0 [COLOR="Blue"]Then[/COLOR]
            Cells(i, "A").EntireRow.Hidden = [COLOR="Blue"]True[/COLOR]
        [COLOR="Blue"]End[/COLOR] [COLOR="Blue"]If[/COLOR]
    [COLOR="Blue"]Next[/COLOR]
    
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0
Not at all! :) It's possible to write even more shorter:
Code:
[COLOR="Blue"]Sub[/COLOR] FFF()

    [COLOR="Blue"]Dim[/COLOR] i [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Long[/COLOR]
    
    [COLOR="Blue"]For[/COLOR] i = 4 [COLOR="Blue"]To[/COLOR] 65
        Cells(i, "A").EntireRow.Hidden = WorksheetFunction.Sum(Range("C" & i & ":G" & i)) = 0
    [COLOR="Blue"]Next[/COLOR]
    
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,277
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