Run a macro only once from a template...

shajueasow

Well-known Member
Joined
Oct 7, 2004
Messages
1,926
Hi,
I have a template with some macros in it. Is it posibble to run an other macro, when template is opened as .xls for the first time. I just want to rename the sheets with dates of the month in which the file is opened. Is it possible?
TIA
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
yes. you can see this in thisworkbook module.

Code:
Private Sub Workbook_Open()
   'your codes here
End Sub
 
Upvote 0
You need to flag somehow if the sheet names has been updated or not.

eg.

If Sheet1.Name = "Sheet1" Then
'''' your code to change sheet names
End If

So that it will run only once
 
Upvote 0
Thanks for both.
But agihcam, your method will always run the macro when the workbook is opened. But I need to run it only once, that is if the sheets are renamed then it shoud not run.
And jindon, that is a nice way that you have suggested. Thank You.
And thanks to agihcam too for sharing his idea.
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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