Require help with VBA code for hiding rows based on cells in range of columns being 0

MonicaP

New Member
Joined
Jan 12, 2022
Messages
6
Office Version
  1. 2010
Platform
  1. Windows
Require help with VBA code for hiding rows based on cells in range of columns being 0
I'm found this code to use but when I use it, it hides all the rows. I need it to hide row if all cells in columns H through L show a 0 value. Can someone please help me with this.

Sub Hide_rows()

Dim LastRow As Long

Dim Rng As Range

LastRow = Range("A125").End(xlUp).Row '

Set Rng = Range("H3:L125")

Application.ScreenUpdating = False

For Each cell In Rng

If cell.Value = "0" Then

cell.EntireRow.Hidden = True

End If

Next cell

Application.ScreenUpdating = True

End Sub
 
You are welcome.
Glad I was able to help!
:)

You can see why I asked it now. That little detail can mean the difference between working and not working.
It is never a bad idea to post a small sample of your data so we can see that, or other little things that may be important.
Many times, the devil is in the details!
I see that. Thanks again, you are a life saver! :)
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
No worries!
Happy Excel-ling!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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