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. :warning: 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

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
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,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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