ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loop across Sheets and number of sheets (https://www.excelbanter.com/excel-programming/285738-loop-across-sheets-number-sheets.html)

Raj[_8_]

Loop across Sheets and number of sheets
 
Dear all,

I request you all to kindly help me with this problem.

We maintain the details of a certain project in one
sheet. One sheet is devoted to only one project wherein
it contains information of the revenue, profitability,
vendors etc. For reporting purposes, for eg. if I have to
find out the status of all the vendors. Then I have to go
through each sheet and find it out.

I wish to create a macro which runs a loop (for, while,
do-while) across the sheets. Can anyone suggest how to
create a loop to cover the sheets. Secondly, is there any
command in VB Editor which can count the total number of
sheets in a file.

Thanking in advance,
Regards
Raj

patrick molloy

Loop across Sheets and number of sheets
 

msgbox "There are " & Activework.Worksheets.Count & _
" sheets"

(example 1)
Dim ThisWS As Worksheet
For Each ThisWS In ActiveWorkbook.Worksheets

Next

(example 2)
Dim index As Long
For index = 1 To ActiveWorkbook.Worksheets.Count

Next


Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Dear all,

I request you all to kindly help me with this problem.

We maintain the details of a certain project in one
sheet. One sheet is devoted to only one project wherein
it contains information of the revenue, profitability,
vendors etc. For reporting purposes, for eg. if I have

to
find out the status of all the vendors. Then I have to

go
through each sheet and find it out.

I wish to create a macro which runs a loop (for, while,
do-while) across the sheets. Can anyone suggest how to
create a loop to cover the sheets. Secondly, is there

any
command in VB Editor which can count the total number of
sheets in a file.

Thanking in advance,
Regards
Raj
.


Raj[_8_]

Loop across Sheets and number of sheets
 
Hi Patrick,

Thanks a lot for the prompt response. I shall definitely
try this and come back in case I face any problems

Raj
-----Original Message-----

msgbox "There are " & Activework.Worksheets.Count & _
" sheets"

(example 1)
Dim ThisWS As Worksheet
For Each ThisWS In ActiveWorkbook.Worksheets

Next

(example 2)
Dim index As Long
For index = 1 To ActiveWorkbook.Worksheets.Count

Next


Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Dear all,

I request you all to kindly help me with this problem.

We maintain the details of a certain project in one
sheet. One sheet is devoted to only one project wherein
it contains information of the revenue, profitability,
vendors etc. For reporting purposes, for eg. if I have

to
find out the status of all the vendors. Then I have to

go
through each sheet and find it out.

I wish to create a macro which runs a loop (for, while,
do-while) across the sheets. Can anyone suggest how to
create a loop to cover the sheets. Secondly, is there

any
command in VB Editor which can count the total number

of
sheets in a file.

Thanking in advance,
Regards
Raj
.

.



All times are GMT +1. The time now is 09:45 AM.

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