Autorun a macro upon opening of excel file

MrDB4Excel

Board Regular
Joined
Jan 29, 2004
Messages
81
I am trying to get a macro to autorun when I open a workbook.
I want this macro to run automatically as soon as I have selected the "Update" selection that appears in the "This workbook contains links to one or more external sources that could be unsafe."
Obviously these sources exist only on my PC and thus are trusted, so this is not an issue.
When I select "Update" I expect the macro to autorun, but alas it does nothing.
The specific macro I want to run is called RunThemAll and it goes as follows:
Sub RunThemAll()
Range("T12").Select
Application.Run "USD2CZK"
Range("T14").Select
Application.Run "EUR2CZK"
Range("T16").Select
Application.Run "CZK2EUR"
Range("T18").Select
Application.Run "RUB2EUR"
Range("T20").Select
Application.Run "EUR2RUB"
Range("A2").Select
Range("J23").Select
End Sub

I have tried the following and all of these were inserted in a double click of "ThisWorkbook" and not added in a module.
Each of the Application.Run "USD2CZK", "EUR2CZK", "CZK2EUR", "RUB2EUR" & "EUR2RUB" all exist in separate modules as seen below in the RunThemAll macro.
What am I doing wrong?

Private Sub Workbook_Open()
Call RunThemAll
End Sub

&

Private Sub Workbook_Open()
Sub RunThemAll()
Range("T12").Select
Application.Run "USD2CZK"
Range("T14").Select
Application.Run "EUR2CZK"
Range("T16").Select
Application.Run "CZK2EUR"
Range("T18").Select
Application.Run "RUB2EUR"
Range("T20").Select
Application.Run "EUR2RUB"
Range("A2").Select
Range("J23").Select
End Sub
End Sub

&

Private Sub Workbook_Open()

End Sub
Sub RunThemAll()
Range("T12").Select
Application.Run "USD2CZK"
Range("T14").Select
Application.Run "EUR2CZK"
Range("T16").Select
Application.Run "CZK2EUR"
Range("T18").Select
Application.Run "RUB2EUR"
Range("T20").Select
Application.Run "EUR2RUB"
Range("A2").Select
Range("J23").Select
End Sub
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

mole999

Moderator
Joined
Oct 23, 2004
Messages
10,099
Office Version
2019, 2016, 2013
Platform
Windows
Code:
Private Sub Workbook_Open()
RunThemAll()
End Sub
Sub RunThemAll()
Range("T12").Select
Application.Run "USD2CZK"
Range("T14").Select
Application.Run "EUR2CZK"
Range("T16").Select
Application.Run "CZK2EUR"
Range("T18").Select
Application.Run "RUB2EUR"
Range("T20").Select
Application.Run "EUR2RUB"
Range("A2").Select
Range("J23").Select
End Sub

or

Private Sub Workbook_Open()
Range("T12").Select
Application.Run "USD2CZK"
Range("T14").Select
Application.Run "EUR2CZK"
Range("T16").Select
Application.Run "CZK2EUR"
Range("T18").Select
Application.Run "RUB2EUR"
Range("T20").Select
Application.Run "EUR2RUB"
Range("A2").Select
Range("J23").Select
End Sub
 

MrDB4Excel

Board Regular
Joined
Jan 29, 2004
Messages
81
Many thanks, mole999. Second code worked. First did not, but no matter because the second code works very well.
 

Forum statistics

Threads
1,089,202
Messages
5,406,814
Members
403,107
Latest member
kyriakos kyriakou

This Week's Hot Topics

Top