un-hiding hidden cells :P

zilch4ry

Board Regular
Joined
Feb 27, 2011
Messages
76
hi all,

i have this code (i had a lot of help from this website already!) which hides all rows which have a value of 0, but the problem im having is if the customer go back and change one of their orders to 1 the macro still shows the row as hidden. I was wondering if anybody could possibly show me what to add to the end of this code for it to unhide rows, once a value of 1 or higher has been entered.

here's the code:

Code:
Sub subb()
Application.ScreenUpdating = False

Dim r As Long, LR As Long, stxt As String
LR = Cells(Rows.Count, "G").End(xlUp).Row
        For r = LR To 2 Step -1
                If Range("G" & r).Value = 0 Then
                    Rows(r).EntireRow.Hidden = True
                End If
        Next r
End Sub

Thanks in advance,


Tom

---- Is there also a way of having the macro run all of the time? so that it updates without the user having to manually click the assigned button. thanks again ;)
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Try

Code:
Sub subb()
Application.ScreenUpdating = False
Dim r As Long, LR As Long, stxt As String
LR = Cells(Rows.Count, "G").End(xlUp).Row
For r = LR To 2 Step -1
    Rows(i).Hidden = Range("G" & r).Value = 0
  
Next r
End Sub
 
Upvote 0
thank you for the answer, but I was given an error. It said there was an "application-defined or object-defined error" highlighting the

Code:
    Rows(i).Hidden = Range("G" & r).Value = 0

row. Any ideas? I'm very bad at visual basic
 
Upvote 0
Sorry, it should be

Rich (BB code):
Rows(r).Hidden = Range("G" & r).Value = 0
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,844
Members
452,948
Latest member
UsmanAli786

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