VBA or Macro that would hide all worksheets with certain text

cbarryb

New Member
Joined
Jun 1, 2012
Messages
34
Office Version
  1. 365
Platform
  1. Windows
  2. Web
Hi All,

Would anyone know how to write the code for being able to hide all worksheets with the text USD and EUR in. I use a module to consolidate all worksheets from a specified folder into one workbook, I just would like to hide all of the Worksheets that have the text USD and EUR in so Im left with the GBP tabs. They all have a date at the beginning i.e. 01.01.2020 USD, so it will need the wildcard char in there. I will then convert all the data to tables and then use Power Query to drag all my data into one Sheet.

Would anyone know what I could do please.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Do you mean that the sheet names contain USD EUR etc?
 
Upvote 0
Yes, they would be called:

01.01.2020 USD
&
01.01.2020 EUR
etc
 
Upvote 0
In that case how about
VBA Code:
Sub cbarryb()
   Dim Ws As Worksheet
   For Each Ws In Worksheets
      If Ws.Name Like "*USD" Or Ws.Name Like "*EUR" Then
         Ws.Visible = xlSheetHidden
      End If
   Next Ws
End Sub
 
Upvote 0
In that case how about
VBA Code:
Sub cbarryb()
   Dim Ws As Worksheet
   For Each Ws In Worksheets
      If Ws.Name Like "*USD" Or Ws.Name Like "*EUR" Then
         Ws.Visible = xlSheetHidden
      End If
   Next Ws
End Sub

Thats worked perfect thank you
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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