is it possible to have macro to auto name worksheet

wally32

New Member
Joined
Mar 7, 2011
Messages
29
hi

not sure whether this is possible. i have a macro which automatically runs a pivottable. the macro is run on a once month basis. the pivottable that is produced comes on a new worksheet, which is named Sheet 1 or 2 or 3, by the system etc. depending on what month it is i.e. sheet 1 would be analysis jan, sheet 2 analysis feb and so on.
what i would like to do is when the new pivottable worksheet is produced is to automatically name it depending what month it is eg. analysis jan,

can someone please advise if this is possible

thanks
 

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.
Perhaps like this

Code:
ActiveSheet.Name = "Analysis " & Format(Date, "mmmm")
 
Upvote 0
thanks for the swift response.the code for the pivot table macro is as follows
Option Explicit
Sub Testcreatepivottable()
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
ActiveSheet.Range("B1:C1").CurrentRegion).CreatePivotTable TableDestination:="", TableName:= _
"PivotTable1", DefaultVersion:=xlPivotTableVersion10
With ActiveSheet
.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
ActiveSheet.PivotTables("PivotTable1").AddDataField ActiveSheet.PivotTables( _
"PivotTable1").PivotFields("Score"), "Count of Score", xlCount
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Region")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Appellant")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Prop no.")
.Orientation = xlRowField
.Position = 2
End With
With ActiveSheet.PivotTables("PivotTable1").PivotFields("Score")
.Orientation = xlColumnField
.Position = 1
End With
ActiveSheet.PivotTables("PivotTable1").TableStyle2 = "PivotStyleMedium2"

End Sub
 
Upvote 0
Just add Peter's code to the end of what you posted and it should be fine! (before the End Sub line)
 
Upvote 0

Forum statistics

Threads
1,214,620
Messages
6,120,559
Members
448,970
Latest member
kennimack

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