Workbook_Open

Pondcroft13

New Member
Joined
May 27, 2010
Messages
32
Hi All,

I am using part of the below formula to always start with the sheet "Dynamic UI" when the workbook is opened. It is not working.

Any ideas?

Private Sub Workbook_Open()

Dim frmSplash As GPUActionsLog
'Show the form modelessly
Set frmSplash = New GPUActionsLog
frmSplash.Show vbModeless
'Process the startup code
Application.Wait Now + TimeValue("00:00:5")
'Unload the splash screen
Unload frmSplash
Set frmSplash = Nothing
'open at a sheet (and range) you want regardless
'of whether or not the sheet has been renamed

'Set the sheet to open (use its codename here)
Const StartUpSheet = "Dynamic UI"

'Set the cell to activate
Const StartUpCell = "A1"

Dim N&
For N = 1 To Sheets.Count
If Sheets(N).CodeName = StartUpSheet Then
Sheets(N).Activate
Range(StartUpCell).Activate
Exit For
End If
Next

End Sub

Kind regards,

Chris
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Hi Chris,

Sheets("Dynamic UI").Activate

So long as the sheets name isn't changed.

ColinKJ
 
Upvote 0
FYI, the sheet's codename could never be "Dynamic UI" as codenames cannot contain spaces.
 
Upvote 0
Replace
Code:
'Set the sheet to open (use its codename here)
Const StartUpSheet = "Dynamic UI"
 
'Set the cell to activate
Const StartUpCell = "A1"
 
Dim N&
For N = 1 To Sheets.Count
If Sheets(N).CodeName = StartUpSheet Then
Sheets(N).Activate
Range(StartUpCell).Activate
Exit For
End If
Next

with either
Code:
Dynamic_UI.Range("A1").Activate
Or
Code:
Sheets("Dynamic UI").Range("A1").Activate
Depending if "Dynamic UI" is the Tab name of the Sheet or if you rewrote Excel to allow you to use a space in the Codename.

You can tell the difference in the VBA editor by looking at the Sheet names in the Project Explorer window. The CodeNames are not enclosed in parentheses and the Tab names are.

In a new workbook with no changes
Code:
Sheet1(Sheet1)
If you rename the Sheet1 Tab to "First Sheet"
Code:
Sheet1(First Sheet)
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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