Worksheet name w/nonvolitile date

drayneal

New Member
Joined
Feb 4, 2008
Messages
10
Hello gurus, I need VBA help. I've searched the forums but found nothing specific to worksheet names. I have a workbook that creates an inventory catalog based on the date. The user wants the date name on the workbook sheet tab, which I have done. However it changes each time its opened. Can the code be made non-volitile. :eek: I'm a novice so go easy. There's a lot more code but this is the relevant part.

Sub DateSheet()
Dim TB As Worksheet
Dim dt As String
dt = Format(Date, "mmm-dd-yyyy")
Set TB = ActiveSheet
TB.Copy after:=Worksheets(Worksheets.Count)
ActiveSheet.Name = CStr(dt) & " Stock Cat Alpha"
End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
However it changes each time its opened.
It shouldn't, unless you call the macro each time the workbook is opened.

It is hard to say how you should structure everything, since we don't really know all that is supposed to happen every single time the sheet is opened. Maybe you need to split your macro into two parts, one that is only run one-time, and one that gets runs every time the workbook is opened.

If you provide more detail regarding what is supposed to happen each time (and all that your code does), we can probably help you sort those details out.
 
Upvote 0
Aaargh.. your're right. While working on the rest of the code I'm inadvertently rerunning the macro. thx Joe4. Told u I was a newbie.
 
Upvote 0
Aaargh.. your're right. While working on the rest of the code I'm inadvertently rerunning the macro. thx Joe4. Told u I was a newbie.
No worries, we have all been there!:biggrin:
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,767
Members
449,049
Latest member
greyangel23

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