Workbook_Open, run macro after cell is selected

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
With respect to the event "Workbook_Open", I wanted to call up a macro called Input, which has a relationship with the active cell.
The problem is that Workbook_Open may be too early to pick up the active cell.
Is there an event which triggers after the workbook is opened and a cell is selected?

VBA Code:
Private Sub Workbook_Open()
    Application.Run "Input"
End Sub

Private Sub Input()
    If ActiveCell.Characters(1, 1).Font.Name Like "Arial" Then
        'Some input here
    End If
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Is the cell always the SAME cell ?
- use workbook_open to activate the correct sheet and select the cell

Should the user asked to select the cell ? You could use something like this
VBA Code:
Private Sub Workbook_Open()
    Dim Cel As Range
    Sheets("Sheet1").Activate
    Set Cel = Application.InputBox("Select a cell...", "Input", , , , , , 8)
    Cel.Select
    Application.Run "Input"
End Sub
 
Upvote 0
Thanks for responding.
The cell would be that last selected before closing the workbook.
I was hoping not to introduce a new step.
Possibly using one from the list below? Maybe it's not possible.

Activate
AddinInstall
AddinUninstall
AfterRemoteChange
AfterSave
AfterXmlExport
AfterXmlImport
BeforeClose
BeforePrint
BeforeRemoteChange
BeforeSave
BeforeXmlExport
BeforeXmlImport
Deactivate
ModelChange
NewChart
NewSheet
Open
PivotTableCloseConnection
PivotTableOpenConnection
RowsetComplete
SheetActivate
SheetBeforeDelete
SheetBeforeDoubleClick
SheetBeforeRightClick
SheetCalculate
SheetChange
SheetDeactivate
SheetFollowHyperlink
SheetLensGalleryRenderComplete
SheetPivotTableAfterValueChange
SheetPivotTableBeforeAllocateChanges
SheetPivotTableBeforeCommitChanges
SheetPivotTableBeforeDiscardChanges
SheetPivotTableChangeSync
SheetPivotTableUpdate
SheetSelectionChange
SheetTableUpdate
Sync
WindowActivate
WindowDeactivate
WindowResize
 
Upvote 0
You are in danger of over-thinking this ;)

Test what happens when you save and reopen a workbook
- save it with a different active cell each time

Which cell is active when the workbook re-opens ?
- it is always the cell that was active when the workbook was saved and closed

So ...
... unless there is something else happening to change normal Excel behaviour ...
...... the cell last selected before closing the workbook
......... is the active cell when the workbook opens
 
Last edited:
Upvote 0
Create a new workbook, add the code below in ThisWorkbook module, and save and close with a different active cell a few times
It ALWAYS reports the cell that was active when the workbook was closed

VBA Code:
Private Sub Workbook_Open()
MsgBox ActiveCell.Address
End Sub
 
Upvote 0
Yes you are right.
Apologies for the inconvenience then.
I don't know why it works now and not then.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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