Workbook Open Event

  • Thread starter Thread starter Stuart
  • Start date Start date
S

Stuart

User opens a workbook with a single sheet.
If I know the sheetname, how may I code:

If the activesheet's name is "abc" Then
in the workbook open event.

Regards
 
'Try Pasting this on the thisworkbook window in VBE

Private Sub Workbook_Open()

Dim lMsg As Long
Dim strSheet As String

strSheet = "Sheet1"

If ActiveSheet.Name = strSheet Then
lMsg = MsgBox("The Active Sheet is: " &
ActiveSheet.Name)
Else
lMsg = MsgBox("The Active Sheet is: " &
ActiveSheet.Name & Chr(10) & Chr(10) & "Not: " & strSheet)
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top