Macro to select sheets in a dynamic list (Named) containing all the sheets' names

akakak

New Member
Joined
Feb 24, 2015
Messages
2
Hi All

My workbook has sheets named from A to Z and a Master-sheet with values auto-populated from sheets A-Z. A dynamic list on Mastersheet updates itself based on which sheets have values greater than Zero. That dynamic list only has the letters A,B,C - Z (excludes tabs which have total value of "0")

I would like a macro able to select only the sheets in that dynamic validation list. The list is named "PdfPrintOfTabsWithData".

Would someone be so kind to let me have a macro that selects sheets based on info on a named list?

Best

AKAKAK
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Hello and welcome to MrExcel

Try the following code:
Code:
Sub SelectSheets()

Dim shtNames As Variant

With ThisWorkbook
    shtNames = .Sheets("Master").Range("PdfPrintOfTabsWithData")
    shtNames = Application.WorksheetFunction.Transpose(shtNames)
    .Sheets(shtNames).Select
End With

End Sub

Change the master sheet name that I have used "Master" to the actual name of your master sheet.

I trust this helps
Andrew
 
Upvote 0
Hi there

Thanks for the reply, however I got this error:

Run-time error '1004': Application-defined or object-defined error. If clicked on Debug the following line is in yellow:

shtNames = .Sheets("Master").Range("PdfPrintOfTabsWithData")

Please could you take a look again!
 
Upvote 0
Hi

The macro assumes there is a sheet called "Master" and on that sheet there is a named range called "PdfPrintOfTabsWithData".

If that is not quite right, then either change the sheet name/named range to suit or amend the macro so that it has the same names that you currently have.

Andrew
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,981
Members
449,276
Latest member
surendra75

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