ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Is there an object containing the sheet names for a workbook (https://www.excelbanter.com/excel-programming/396671-there-object-containing-sheet-names-workbook.html)

Niklas M

Is there an object containing the sheet names for a workbook
 
Hi,
here's the problem.
I have worksheets containing the same kind of data and would like to
consolidate data from the sheet with some restrictions. And I would like
construct some sort of macro for this task since it will be repeated quite
often. But the set of sheets in the workbook will probeably change over time.
Is there a method for finding the names of the sheets in an workbook so that
a could loop over the existing sheets?

/Niklas

Gary''s Student

Is there an object containing the sheet names for a workbook
 
Sub saysheet()
For Each sh In Worksheets
MsgBox (sh.Name)
Next
End Sub

--
Gary''s Student - gsnu200741


"Niklas M" wrote:

Hi,
here's the problem.
I have worksheets containing the same kind of data and would like to
consolidate data from the sheet with some restrictions. And I would like
construct some sort of macro for this task since it will be repeated quite
often. But the set of sheets in the workbook will probeably change over time.
Is there a method for finding the names of the sheets in an workbook so that
a could loop over the existing sheets?

/Niklas


Bob Phillips

Is there an object containing the sheet names for a workbook
 
There is also Worksheets.Count that tells you how many worksheets, or
Sheets.Count that tells you the number of sheets (worksheets, charts, etc.)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Gary''s Student" wrote in message
...
Sub saysheet()
For Each sh In Worksheets
MsgBox (sh.Name)
Next
End Sub

--
Gary''s Student - gsnu200741


"Niklas M" wrote:

Hi,
here's the problem.
I have worksheets containing the same kind of data and would like to
consolidate data from the sheet with some restrictions. And I would like
construct some sort of macro for this task since it will be repeated
quite
often. But the set of sheets in the workbook will probeably change over
time.
Is there a method for finding the names of the sheets in an workbook so
that
a could loop over the existing sheets?

/Niklas





All times are GMT +1. The time now is 11:10 PM.

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