ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   FILTER SHEETS BY NAME (https://www.excelbanter.com/excel-programming/303685-filter-sheets-name.html)

SUNIL

FILTER SHEETS BY NAME
 
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



Frank Kabel

FILTER SHEETS BY NAME
 
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

--
Regards
Frank Kabel
Frankfurt, Germany


SUNIL wrote:
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


Chip Pearson

FILTER SHEETS BY NAME
 
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



"SUNIL" wrote in message
...
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





Don Guillett[_4_]

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

--
Don Guillett
SalesAid Software

"SUNIL" wrote in message
...
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






All times are GMT +1. The time now is 03:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com