Always open workbook on sheet called "HOME"

APML

Board Regular
Joined
Sep 10, 2021
Messages
216
Office Version
  1. 365
Hi all, I'm not very good at VBA and had lots of help building the code below...just want to modify so the workbook always opens on the sheet called Journal,
I've got the following code already in the VBA section "This WorkBook" and have added the final part of the code which I hoped would get it to open on the worksheet called "Journal" (see the very last part of the code below)
but I'm getting a Compile error: Ambiguous name detected: Workbook_Open

Was hoping someone would be able to help me fix

Private Sub Workbook_Open()
Call Initialise
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
blnClosing = True
dteEarliestTime = Now + TimeSerial(0, 0, 1)
Application.OnTime dteEarliestTime, "IsThisClosed"
End Sub

Private Sub Workbook_Activate()
Call Initialise(True)
End Sub

Private Sub Workbook_Deactivate()
If blnClosing Then
Application.OnTime dteEarliestTime, "IsThisClosed", , False
Else
Call DeInitialise
End If
End Sub

Private Sub Worksheet_Deactivate()
Call DeInitialise
End Sub

Private Sub Worksheet_Activate()
Call Initialise
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

On Error Resume Next
If Sh.Name = "Analyse" Then
MsgBox "ALWAYS REFRESH DATA Before Using This Sheet", vbInformation, "INBUILT, A Smarter Way To Trade"

End If


On Error Resume Next
If Sh.Name = "Calendar" Then
MsgBox "ALWAYS REFRESH DATA Before Using This Sheet", vbInformation, "INBUILT, A Smarter Way To Trade"

End If
End Sub

Private Sub Workbook_Open()
Sheets("Journal").Select
Range ("A1")
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
You cant have two workbook open macros so just add your code to the one you already have.
 
Upvote 0
In what you provided there are two workbook open macros. You can only have one.
 
Upvote 0
Try this:

VBA Code:
Private Sub Workbook_Open()
Call Initialise
worksheets("Journal").activate 
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
blnClosing = True
dteEarliestTime = Now + TimeSerial(0, 0, 1)
Application.OnTime dteEarliestTime, "IsThisClosed"
End Sub

Private Sub Workbook_Activate()
Call Initialise(True)
End Sub

Private Sub Workbook_Deactivate()
If blnClosing Then
Application.OnTime dteEarliestTime, "IsThisClosed", , False
Else
Call DeInitialise
End If
End Sub

Private Sub Worksheet_Deactivate()
Call DeInitialise
End Sub

Private Sub Worksheet_Activate()
Call Initialise
End Sub

Private Sub Workbook_SheetActivate(ByVal Sh As Object)

On Error Resume Next
If Sh.Name = "Analyse" Then
MsgBox "ALWAYS REFRESH DATA Before Using This Sheet", vbInformation, "INBUILT, A Smarter Way To Trade"

End If


On Error Resume Next
If Sh.Name = "Calendar" Then
MsgBox "ALWAYS REFRESH DATA Before Using This Sheet", vbInformation, "INBUILT, A Smarter Way To Trade"

End If
End Sub
 
Upvote 0
Use this code: copy in Workbook: Anytime when you open the workbook will be the Tab Name "Journal".

Private Sub Workbook_Open()

Sheets("Journal").Select

Sheets("Journal").Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,499
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top