Auto hide/unhide protected rows in excell

Mngazija

New Member
Joined
Jul 7, 2021
Messages
7
Office Version
  1. 2013
Platform
  1. Windows
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
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshots (not a pictures) of both sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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