Autorun a macro upon opening of excel file

MrDB4Excel

Active Member
Joined
Jan 29, 2004
Messages
327
Office Version
  1. 2013
Platform
  1. Windows
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
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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
 
Upvote 0
Many thanks, mole999. Second code worked. First did not, but no matter because the second code works very well.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,207
Members
448,554
Latest member
Gleisner2

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