Pivot Range Name

  • Thread starter Thread starter Lift Off
  • Start date Start date
L

Lift Off

I have a macro I recorded and am now trying to tweek with VBA to make i
more accurate. In the recorder I got the pivot source from naming
large cell range, some of which I don't need.

Trying to make the source dynamic but first was just trying to "name
the range for the source data to pull from. Here's the pivo
generation statement:

ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:
"R2C1:R2800C26").CreatePivotTable _
TableDestination:="", TableName:="PivotTable4"

Trying to name a range to replace "R2C1:R2816C26", but get an erro
code when it runs. Below is the code to set the range name.

Dim RawData As Range
Set RawData = Range("R2C1:R2800C26")

Get "error 1004, Method 'Range' of object '_Global failed"

What am I doing wrong? TIA Lift Of
 
According to VBA Help, RANGE has to be in A1 style
notation. Yours is R1C1.

Cheers, Pete.
 
Pete: I had printed off and marked that line with a hi-liter, but di
not make the connection as recording the macro listed it in relativ
style. Lesson learned! Thanks for taking the time to help me. Lif
Of
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top