VBA- if many columns in a given row are all 0, hide the row and the one below it :/

D_Licious

New Member
Joined
May 6, 2015
Messages
11
hello wonderful Excel community,

i'm trying to use VBA to hide all given rows and the one below each said row (this applies to all rows within a given worksheet) if the column values for a given row in C, D, F, G, J & K all have a zero in it....... i'm not looking for them all to add up to 0, but just for each of them to individually be 0.

the reason i need to hide the one below it too is because this is a set of data with skipped lines, so every line (row) of data is followed by a blank row with nothing in it

Example- C16, D16, F16, G16, J16 and K16 all have the number zero in it. I need rows 16 and 17 both hidden.

there are many rows where this happens each month but it's not predictable which ones, and i'd like to be able to do it with VBA to save manual formatting time,

thank you so much!!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
This should make pretty quick work of the task...
VBA Code:
Sub d_licious()
Dim i As Long, lastrow As Long
lastrow = Range("A1").SpecialCells(xlCellTypeLastCell).Row

For i = lastrow To 1 Step -1
    If Cells(i, 3) & Cells(i, 4) & Cells(i, 6) & Cells(i, 7) & Cells(i, 10) & Cells(i, 11) = "000000" Then Cells(i, 1).Resize(2).EntireRow.Hidden = True
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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