Hi guys, I am new in VBA ,currently I am working in the excel which has sheets linked to each other with the formulas, for example in sheet 1 have the column for names, those names are linked in sheet 2 however sheet 2 is protected, is there a code for auto hide/unhide sheet 2 if the name either entered or removed, currently I am using the following code in sheet 2 but in the unprotected mode however the code goes very slow to hide or unhide the rows:
Private Sub Worksheet_Activate()
Dim r As Long
Dim m As Long
Application.ScreenUpdating = False
Me.Range("E:E").EntireRow.Hidden = False
m = Range("E" & Me.Rows.Count).End(xlUp).Row
For r = 6 To m
If Range("E" & r).Value = "" Or Range("E" & r).Value = "0" Then
Range("E" & r).EntireRow.Hidden = True
End If
Next r
Application.ScreenUpdating = True
End Sub
I will appreciate to know what should I do to make the code run fast, I have 1000 rows, also if I can get the code to add in sheet 2 in order to work in the protected sheet will be wonderful.
Thanks, Really appreciate your help.
Rasul
Private Sub Worksheet_Activate()
Dim r As Long
Dim m As Long
Application.ScreenUpdating = False
Me.Range("E:E").EntireRow.Hidden = False
m = Range("E" & Me.Rows.Count).End(xlUp).Row
For r = 6 To m
If Range("E" & r).Value = "" Or Range("E" & r).Value = "0" Then
Range("E" & r).EntireRow.Hidden = True
End If
Next r
Application.ScreenUpdating = True
End Sub
I will appreciate to know what should I do to make the code run fast, I have 1000 rows, also if I can get the code to add in sheet 2 in order to work in the protected sheet will be wonderful.
Thanks, Really appreciate your help.
Rasul