What do i did about array sheets selection when they change the name?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I have a document that we got someone to do some work on and when it came back some of the sheets have been renamed In the Project Widow (I hopes thats correct)

So Instead of
Sheet16(Dashboard)
we have
wsDashboard(Dashboard)

now this has coused me a problem with this code and I'm not sure whats wrong?
Code:
Sub Selt_Shts1() 
Dim ws As Sheet
For Each ws In Array(wsData, wsProd, wsMarket, wsChars, wsDelivery, wsDevelopit)
ws.Select
ActiveWindow.DisplayHeadings = False
ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Next ws
end sub
[LEFT][COLOR=#222222][FONT=Verdana]
[/FONT][/COLOR][/LEFT]

Now the "wsData" is the first part and we want to use this so if the sheet gets renamed it still runs
but everytime I run it I get debug Object required

Please Help
Thanks
Tony
 

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.
If it's called wsDashboard, why are you using wsData?
 
Upvote 0
Hi Rory,
Sorry to confuse there are lots of tabs the ones in the array are the ones i want the macro to run on :-)
 
Upvote 0
Try changing the Dim statement to
Code:
   Dim ws As Variant
 
Upvote 0
You're welcome & thanks for the feedback
 
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