FILTER SHEETS BY NAME

S

SUNIL

how can a piece of code be run on every sheet whose name that begins with
"buy", in a particular workbook ?

Thanks in anticipation

Sunil
 
F

Frank Kabel

Hi
try something like the following:
sub foo()
dim wks as worksheet
for each wks in activeworkbook.worksheets
if lcase(left(wks.name,3))="buy" then
msgbox wks.range("A1").value
'your code
end if
next
end sub
 
C

Chip Pearson

Try something like

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
If WS.Name Like "Buy*" Then
' do something with WS
End If
Next WS


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
D

Don Guillett

try this
for each ws in worksheets
if left(ws.name,3)="buy" then runmycode
next ws
 
Top