Hiding Sheets if I have a Worksheet Selection Change

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi

I can hide the rows I want by using
VBA Code:
Rows("23:35").EntireRow.Hidden = True or Rows("23:35").Hidden = True

However I have a worksheet selection change which does some stuff when selecting rows 10 to 100 and I get an error
run time error 1004 - Unable to set the Hidden property of the Range class

I tried turning off application.enableevents but still same error
VBA Code:
Application.EnableEvents = False
  Rows("23:35").EntireRow.Hidden = True
Application.EnableEvents = True
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
it was but the code unprotected it before it unhid the Rows.

Just realised however the worksheet change event unprotected and protected the sheet so I've just added another line before the unhide which seems to have done the trick

Maybe I should have added the code to the worksheet change when it was unprotected if a certain cell contained a certain value. instead i added it to the sub in question although don't think it would have made much of a difference
 
Upvote 0
Glad you've sorted it & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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