I am attempting to select all sheets with names containing "* +H" (there are many) to allow me to paste a block of data to all sheets selected.
The following block of code does what I need however if there were any sheets already selected it adds these sheets to the selection even if they don't meet the "* +H" criteria.
What is the best way to add to this code to deselect any selected sheets that don't qualify? Or should I attack this from a different angle?
No doubt there are multiple ways to achieve this but hoping for something simple without bloating my code.
I've run the same code twice with the first time "Replace:=True" and second time "Replace:=False". It works but seems like a dodgy workaround.
Is there a "nicer" way?
The following block of code does what I need however if there were any sheets already selected it adds these sheets to the selection even if they don't meet the "* +H" criteria.
What is the best way to add to this code to deselect any selected sheets that don't qualify? Or should I attack this from a different angle?
No doubt there are multiple ways to achieve this but hoping for something simple without bloating my code.
I've run the same code twice with the first time "Replace:=True" and second time "Replace:=False". It works but seems like a dodgy workaround.
Is there a "nicer" way?
VBA Code:
For j = 1 To ThisWorkbook.Sheets.Count
If Sheets(j).Name Like "* +H" Then Sheets(j).Select Replace:=False
Next j