Activate Multiple Worksheets based off List of Names

jodigif

New Member
Joined
Apr 4, 2012
Messages
4
I have list of the names in an excel worksheet. I would like to activate only the worksheets that are included in that list. Can anyone please help??
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Just a little more information about what you mean by "activate"
Typically "activate" means to "go to" or "switch to" such as go to cell A1 or switch to Sheet1.
So when you say "activate" does it cycle through the sheets?
Gary
 
Upvote 0
Not sure if I am not asking the right question yet.
Keep trying to help me understand what you want to do.

I read you want to, "activate only the worksheets that are included in that list"

Are they going to be activated one at a time so you can do something on the sheet, or all at once like you are going to copy/move them to a new workbook?

Once activated, what do you want to do with them?

Gary
 
Upvote 0
Hi
Sorry it is isn't clear

I mean the second scenerio "all at once like you are going to copy/move them to a new workbook?"

I already have the macro written to move them to a new sheet. I just can't figure out how to select all the sheets based off of the list.

Thanks
Jodi
 
Upvote 0
Try this:

<font face=Calibri><SPAN style="color:#00007F">Sub</SPAN> ArrayRange()<br>    <SPAN style="color:#00007F">Dim</SPAN> tmpArray(1 <SPAN style="color:#00007F">To</SPAN> 10) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> x = 1 <SPAN style="color:#00007F">To</SPAN> 10<br>        tmpArray(x) = Sheets("Sheet1").Range("A" & x).Value<br>    <SPAN style="color:#00007F">Next</SPAN> x<br>    Sheets(tmpArray).Copy<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

There is a little more eloquent way to handle the array size, but to get started this is easier to understand.
This example is saying your first ten rows are the ones you want to copy

Gary
 
Last edited:
Upvote 0
Thank you!! , that is selecting the correct sheets and moving them out.
Can you tell me how to change the value where it shows 10 to be linked to an excel cell.
 
Upvote 0
Well, this is the part where I was talking there are nicer ways of working with arrays.

If I understand what you mean by "value to be be linked to an excel cell", then you will have a number in that cell to tell it how many sheets to move. Then the following code checks cell B1 for a value of how any sheets to copy and then "Redim"s the array to that value.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> ArrayRange()<br>r = Sheets("Sheet1").Range("B1").Value<br>    <SPAN style="color:#00007F">ReDim</SPAN> tmpArray(1 <SPAN style="color:#00007F">To</SPAN> r) <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">For</SPAN> x = 1 <SPAN style="color:#00007F">To</SPAN> r<br>        tmpArray(x) = Sheets("Sheet1").Range("A" & x + 1).Value<br>    <SPAN style="color:#00007F">Next</SPAN> x<br>    Sheets(tmpArray).Copy<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Gary
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,849
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