Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Recognizing a Chart Worksheet

I have a macro that performs a function on each sht of a workbook. However,
I'd like it to skip Chart sheets. How can I test that a sheet is a chart so
that an If statement will not process that sheet?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 229
Default Recognizing a Chart Worksheet

Use an Excel.Worksheet object and ThisWorkbook.Worksheets collection.
This does not contain charts.

Another way would be using a method that charts don't have (like
Range) and testing for error - something along the lines of this:

Public Sub testForChart()
Dim wsh As Object
Dim i As Variant

For Each wsh In Excel.Sheets
On Error Resume Next
i = wsh.Range("A1").Value

If Err.Number < 0 Then
Debug.Print "Skipping chart: " & wsh.Name
Err.Clear
Else
Debug.Print wsh.Name
End If
On Error GoTo 0
Next wsh
End Sub


On Oct 30, 6:28 pm, SteveG wrote:
I have a macro that performs a function on each sht of a workbook. However,
I'd like it to skip Chart sheets. How can I test that a sheet is a chart so
that an If statement will not process that sheet?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6,582
Default Recognizing a Chart Worksheet

Declare a variable as a worksheet, then loop through the worksheets
collection:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
etc.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"iliace" wrote in message
oups.com...
Use an Excel.Worksheet object and ThisWorkbook.Worksheets collection.
This does not contain charts.

Another way would be using a method that charts don't have (like
Range) and testing for error - something along the lines of this:

Public Sub testForChart()
Dim wsh As Object
Dim i As Variant

For Each wsh In Excel.Sheets
On Error Resume Next
i = wsh.Range("A1").Value

If Err.Number < 0 Then
Debug.Print "Skipping chart: " & wsh.Name
Err.Clear
Else
Debug.Print wsh.Name
End If
On Error GoTo 0
Next wsh
End Sub


On Oct 30, 6:28 pm, SteveG wrote:
I have a macro that performs a function on each sht of a workbook.
However,
I'd like it to skip Chart sheets. How can I test that a sheet is a chart
so
that an If statement will not process that sheet?





  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Recognizing a Chart Worksheet

Great, this worked well by just avoiding the chart altogether.

"Jon Peltier" wrote:

Declare a variable as a worksheet, then loop through the worksheets
collection:

Dim WS As Worksheet
For Each WS In ActiveWorkbook.Worksheets
etc.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"iliace" wrote in message
oups.com...
Use an Excel.Worksheet object and ThisWorkbook.Worksheets collection.
This does not contain charts.

Another way would be using a method that charts don't have (like
Range) and testing for error - something along the lines of this:

Public Sub testForChart()
Dim wsh As Object
Dim i As Variant

For Each wsh In Excel.Sheets
On Error Resume Next
i = wsh.Range("A1").Value

If Err.Number < 0 Then
Debug.Print "Skipping chart: " & wsh.Name
Err.Clear
Else
Debug.Print wsh.Name
End If
On Error GoTo 0
Next wsh
End Sub


On Oct 30, 6:28 pm, SteveG wrote:
I have a macro that performs a function on each sht of a workbook.
However,
I'd like it to skip Chart sheets. How can I test that a sheet is a chart
so
that an If statement will not process that sheet?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Recognizing *.xls files Nevsky Excel Discussion (Misc queries) 6 October 14th 07 03:05 AM
Recognizing Real Values Ken Excel Discussion (Misc queries) 2 September 18th 07 07:08 AM
Recognizing 2-digit years Dallman Ross Excel Discussion (Misc queries) 12 December 10th 06 08:50 PM
Recognizing #N/A nebb Excel Worksheet Functions 1 October 19th 05 12:56 AM
Recognizing misc. text MeisterHim Excel Discussion (Misc queries) 3 September 20th 05 04:50 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"