dim as long questions

drozek

Board Regular
Joined
Aug 3, 2011
Messages
67
Hi experts

I have a pivot table with values that starts in A3 to N3 and down, but the values down change depending on the week, how would I capture all of them and named them "PivotGrowth" ?

Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
ActiveWorkbook.Names.Add Name:="PivotGrowth", RefersToR1C1:= _
"='by Growth Account'!R3C1:R286C14"
Range("P4").Select
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"PivotGrowth", Version:=6).CreatePivotTable TableDestination:= _
"by Growth Account!R4C16", TableName:="PivotTable1", DefaultVersion:=6
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Is there anything in the first two rows of the sheet, or are they blank?
 
Upvote 0
I'd suggest something like this:

Code:
Dim PivotRange as Range
Set PivotRange = Range("A3").Currentregion
Set pivotrange = Range("A3", pivotrange.cells(pivotrange.cells.count))
pivotrange.name = "PivotGrowth"
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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