Article ID: 108350
Article Last Modified on 10/10/2006
Chart
DialogSheet
Module (except in Microsoft Excel 97 and Microsoft Excel 98)
MS Excel 4.0 Macro Sheet
MS Excel 4.0 International Macro Sheet
Worksheet
Option Explicit
Sub Sheet_Type()
' Dimension variables.
Dim X As Variant
' Iterate through the loop once for each sheet in the workbook.
For Each X In ActiveWorkbook.Sheets
' If the sheet's TypeName is "Worksheet", then...
If TypeName(X) = "Worksheet" Then
' Check for each Type (xlWorksheet, xlExcel4MacroSheet,
' xlExcel4IntlMacroSheet) and display the appropriate
' message box.
If X.Type = xlWorksheet Then
MsgBox "Worksheet"
ElseIf X.Type = xlExcel4MacroSheet Then
MsgBox "MS Excel 4.0 Macro Sheet"
ElseIf X.Type = xlExcel4IntlMacroSheet Then
MsgBox "MS Excel 4.0 International Macro Sheet"
End If
' Otherwise, display a message box with the appropriate
' TypeName.
Else
MsgBox TypeName(X) ' Show sheet type in message box.
End If
Next ' Repeat the loop until finished.
End Sub
When you run the Sheet_Type subroutine, the messages you receive are:
Worksheet, MS Excel 4.0 Macro Sheet, Chart, DialogSheet, Module
Additional query words: 5.00c 7.00a XL98 XL97 XL7 XL5 XL
Keywords: kbdtacode kbhowto kbprogramming KB108350