ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If Active Sheet on Opening is X then do Y (https://www.excelbanter.com/excel-programming/380993-if-active-sheet-opening-x-then-do-y.html)

spences10

If Active Sheet on Opening is X then do Y
 
Hi, I'm having trouble with the below code. I want the open procedure
to exit the code if the active sheet on opening is "Option1" can
anyone help please??

Private Sub Workbook_Open()
Application.ScreenUpdating = False
If ActiveSheet.Name("Option1") Then
Exit Sub
End If
ActiveWorkbook.Sheets("Input").Activate
If Range("D30") < "" Then
ActiveWorkbook.Sheets("Default").Select
Exit Sub
End If
UserForm2.Show
Application.ScreenUpdating = True
End Sub


spences10

If Active Sheet on Opening is X then do Y
 
Hi Galimi,

as instructed i entered the debug and the [same as before] following
error appeared : Run-Time Error '451'

Property let procedurenot defined and property get procedure did not
return an object

I'm totally lost....

Scott

galimi wrote:
It may be showing the workbook name as Option1.xls. To verify, put a
debug.print activesheet.name statement in at the very top of your module.
--
http://HelpExcel.com




"spences10" wrote:

Hi, I'm having trouble with the below code. I want the open procedure
to exit the code if the active sheet on opening is "Option1" can
anyone help please??

Private Sub Workbook_Open()
Application.ScreenUpdating = False
If ActiveSheet.Name("Option1") Then
Exit Sub
End If
ActiveWorkbook.Sheets("Input").Activate
If Range("D30") < "" Then
ActiveWorkbook.Sheets("Default").Select
Exit Sub
End If
UserForm2.Show
Application.ScreenUpdating = True
End Sub




spences10

If Active Sheet on Opening is X then do Y
 
Gary,

Excellent

Thats the one, Thank You

Gary''s Student wrote:
Private Sub Workbook_Open()
If ActiveSheet.Name = "Option1" Then
MsgBox ("because active sheet is Option1, I am leaving")
Exit Sub
End If
End Sub

--
Gary's Student


"spences10" wrote:

Hi, I'm having trouble with the below code. I want the open procedure
to exit the code if the active sheet on opening is "Option1" can
anyone help please??

Private Sub Workbook_Open()
Application.ScreenUpdating = False
If ActiveSheet.Name("Option1") Then
Exit Sub
End If
ActiveWorkbook.Sheets("Input").Activate
If Range("D30") < "" Then
ActiveWorkbook.Sheets("Default").Select
Exit Sub
End If
UserForm2.Show
Application.ScreenUpdating = True
End Sub





All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com