FILTER SHEETS BY NAME

  • Thread starter Thread starter SUNIL
  • Start date Start date
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
 
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
 
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
 
try this
for each ws in worksheets
if left(ws.name,3)="buy" then runmycode
next ws
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top