ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   List Worksheets & Chartsheets (https://www.excelbanter.com/excel-programming/322335-list-worksheets-chartsheets.html)

Blue

List Worksheets & Chartsheets
 
I have the following code, thanks to Jim Thomlinson, problem is it is only
picking up worksheets, I would like it to also list chartsheets as well.
Help need to change code to do this.

Private Sub Worksheet_Activate()
Dim rngToUpdate As Range
Dim wks As Worksheet

Set rngToUpdate = Range("F5")

Application.ScreenUpdating = False
For Each wks In Worksheets
rngToUpdate = wks.Name
Set rngToUpdate = rngToUpdate.Offset(1, 0)
Next wks
Application.ScreenUpdating = True

Set rngToUpdate = Nothing
End Sub


Thanks, Blue



Nick Hodge

List Worksheets & Chartsheets
 
Blue

Change the

Dim wks As Worksheet

to

Dim wks As Object

and change

For each wks in Worksheets

to

For each wks in Sheets

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Blue" wrote in message
. ..
I have the following code, thanks to Jim Thomlinson, problem is it is only
picking up worksheets, I would like it to also list chartsheets as well.
Help need to change code to do this.

Private Sub Worksheet_Activate()
Dim rngToUpdate As Range
Dim wks As Worksheet

Set rngToUpdate = Range("F5")

Application.ScreenUpdating = False
For Each wks In Worksheets
rngToUpdate = wks.Name
Set rngToUpdate = rngToUpdate.Offset(1, 0)
Next wks
Application.ScreenUpdating = True

Set rngToUpdate = Nothing
End Sub


Thanks, Blue




Blue

List Worksheets & Chartsheets
 
Thanks Nick, just what I wanted.

Blue


"Nick Hodge" wrote in message
...
Blue

Change the

Dim wks As Worksheet

to

Dim wks As Object

and change

For each wks in Worksheets

to

For each wks in Sheets

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Blue" wrote in message
. ..
I have the following code, thanks to Jim Thomlinson, problem is it is
only picking up worksheets, I would like it to also list chartsheets as
well. Help need to change code to do this.

Private Sub Worksheet_Activate()
Dim rngToUpdate As Range
Dim wks As Worksheet

Set rngToUpdate = Range("F5")

Application.ScreenUpdating = False
For Each wks In Worksheets
rngToUpdate = wks.Name
Set rngToUpdate = rngToUpdate.Offset(1, 0)
Next wks
Application.ScreenUpdating = True

Set rngToUpdate = Nothing
End Sub


Thanks, Blue







All times are GMT +1. The time now is 07:22 PM.

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