Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Detecting Sheet Type with VBA

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 268
Default Detecting Sheet Type with VBA

You can try
If TypeName(ActiveSheet) ="Chart" or "Worksheet". However, when you spell
Chart as cHart, it will not recognise it. To solve this problem, you can
change your statement to read
If Ucase(TypeName(ActiveSheet)) = Ucase("Chart")

"Type of Sheet displayed" wrote:

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Detecting Sheet Type with VBA

Kassie,

Thank you very much. That worked great!
-- Bryan

"kassie" wrote:

You can try
If TypeName(ActiveSheet) ="Chart" or "Worksheet". However, when you spell
Chart as cHart, it will not recognise it. To solve this problem, you can
change your statement to read
If Ucase(TypeName(ActiveSheet)) = Ucase("Chart")

"Type of Sheet displayed" wrote:

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Detecting Sheet Type with VBA

Here's an alternate approach Brian,

Sub checksheets()

Dim activsht As Variant
Dim activtype As Integer

' check if worksheet
For Each activsht In ActiveWorkbook.Sheets
activtype = activsht.Type

'' -4167 is the type code for a worksheet, 3 is the type code for a chart
If activtype = -4167 Then
'' do some action
MsgBox activsht.Name
Else
'' do something else
MsgBox activsht.Name
End If

Next activsht

End Sub

substitute the msgboxes for the code you want to run.
--
Gene


"Type of Sheet displayed" wrote:

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Detecting Sheet Type with VBA

Gene,

Thank you also, that works as well.

-- Bryan

"Gene" wrote:

Here's an alternate approach Brian,

Sub checksheets()

Dim activsht As Variant
Dim activtype As Integer

' check if worksheet
For Each activsht In ActiveWorkbook.Sheets
activtype = activsht.Type

'' -4167 is the type code for a worksheet, 3 is the type code for a chart
If activtype = -4167 Then
'' do some action
MsgBox activsht.Name
Else
'' do something else
MsgBox activsht.Name
End If

Next activsht

End Sub

substitute the msgboxes for the code you want to run.
--
Gene


"Type of Sheet displayed" wrote:

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Detecting Sheet Type with VBA

Sometimes using the excel constants will help when you read the code later:

xlWorksheet is the same as -4167



Gene wrote:

Here's an alternate approach Brian,

Sub checksheets()

Dim activsht As Variant
Dim activtype As Integer

' check if worksheet
For Each activsht In ActiveWorkbook.Sheets
activtype = activsht.Type

'' -4167 is the type code for a worksheet, 3 is the type code for a chart
If activtype = -4167 Then
'' do some action
MsgBox activsht.Name
Else
'' do something else
MsgBox activsht.Name
End If

Next activsht

End Sub

substitute the msgboxes for the code you want to run.
--
Gene

"Type of Sheet displayed" wrote:

I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Detecting Sheet Type with VBA

Hi Bryan.

Try belowe, please.

Sub shtyp()
MsgBox TypeName(ActiveSheet)
End Sub

'or

Sub SheetTypes()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
msgbox TypeName(sh)
Next
End Sub


--
Best Regards
Joergen Bondesen

"Type of Sheet displayed" <Type of Sheet
wrote in message
...
I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings
but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Detecting Sheet Type with VBA

Joergen,

As with the others, thank you much. This worked very well also.

Bryan

"Joergen Bondesen" wrote:

Hi Bryan.

Try belowe, please.

Sub shtyp()
MsgBox TypeName(ActiveSheet)
End Sub

'or

Sub SheetTypes()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
msgbox TypeName(sh)
Next
End Sub


--
Best Regards
Joergen Bondesen

"Type of Sheet displayed" <Type of Sheet
wrote in message
...
I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck with
it. I have 38 sheets in this application and I'm configuring the workbook
when opened. Some things I'm turing off like the column and row headings
but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Detecting Sheet Type with VBA

If you only want to work with the Worksheets collection instead of the
Sheets collection, so Charts are not even included.
Dim WS as WorkSheet
For Each WS in Worksheets
'etc

NickHK

"Type of Sheet displayed"
wrote in message ...
Joergen,

As with the others, thank you much. This worked very well also.

Bryan

"Joergen Bondesen" wrote:

Hi Bryan.

Try belowe, please.

Sub shtyp()
MsgBox TypeName(ActiveSheet)
End Sub

'or

Sub SheetTypes()
Dim sh As Object
For Each sh In ActiveWorkbook.Sheets
msgbox TypeName(sh)
Next
End Sub


--
Best Regards
Joergen Bondesen

"Type of Sheet displayed" <Type of Sheet
wrote in message
...
I am trying to determine the type of sheet (chart or worksheet) that is
currently active. I was filtering through the documentation and the
xlsheettype seems to be one that I could use but not having much luck

with
it. I have 38 sheets in this application and I'm configuring the

workbook
when opened. Some things I'm turing off like the column and row

headings
but
that doesn't apply to a chart sheet. Anyone have a suggestion?

Thanks,

Bryan






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
type on one sheet automatically apear also on another sheet jrjester Excel Discussion (Misc queries) 1 July 14th 09 01:53 PM
type in one sheet and appear on all sheets bigjim New Users to Excel 7 October 30th 06 04:55 PM
Detecting a sheet unprotect? Don Wiss Excel Programming 2 February 23rd 05 04:17 AM
Detecting Macro Code behind a sheet (2) Chris Gorham[_3_] Excel Programming 10 December 31st 03 06:12 PM
Detecting Macro code behind a sheet Chris Gorham[_3_] Excel Programming 3 December 31st 03 01:39 AM


All times are GMT +1. The time now is 05:07 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"