April 2006
Beginner
1114 pages
98h 16m
English
workbook.ActiveSheet
Returns a reference to the worksheet, chart sheet, Excel 4.0 macro sheet, or Excel 5.0 dialog sheet that currently has focus. In most cases, ActiveSheet returns a reference to the active worksheet, but it is important to make sure that it is a worksheet before proceeding in code. For example, the following code checks whether ActiveSheet is a worksheet before performing some task:
Dim ws As Worksheet
If TypeName(ActiveSheet) = "Worksheet" Then
Set ws = ActiveSheet
ws.Cells(1, 1) = 42
' Some other code...
Else
MsgBox "Please activate a worksheet."
End IfRead now
Unlock full access