0

I have looked at previously answered questions on this subject and tried to apply the answers to my macro but I keep getting run time errors (13)when I try to apply it.I would appreciate any help.

Code:

Sub TestPivot()

Dim test1 As Range

Set test1 = Sheets("Raw Data").Range("B1:T100000")

       Sheets("Summary").PivotTables("PivotTable1").ChangePivotCache ActiveWorkbook. _
        PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        test1 _
        , Version:=xlPivotTableVersion14)

Set test1 = Nothing
End Sub

Thanks,

Ciaran.

1 Answer 1

1

Try this and see if it works:

Sub TestPivot()
       Dim test1 As String

       test1 = "'Raw Data!R1C2:R10000C20'"

       Sheets("Summary").PivotTables("PivotTable1").ChangePivotCache ActiveWorkbook. _
        PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        test1 _
        , Version:=xlPivotTableVersion14)

        test1 = ""
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

I added the missing " and I got it to work. I really apreciate your help.
Yep, sorry about that, I didn't realized that

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.