I've been debugging this code for hours in creating a pivot table, but unfortunately, I'm not able to figure out the problem. It keeps on displaying, Object doesn't support this property or method.
Sub CreatePivotTable()
Dim sht, srcSheet As Worksheet, ccsheet As Worksheet
Dim pvtCache As PivotCache
Dim pvt As PivotTable
Dim StartPvt As String
Dim SrcData As String
Dim lrow As Long
Set srcSheet = ThisWorkbook.Sheets("Document Raw")
lrow = srcSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
Set ccsheet = ThisWorkbook.Sheets("Character Count")
SrcData = srcSheet & "!" & Range("A1:V"& lrow).Address(ReferenceStyle:=xlR1C1)' this is the line that errors
StartPvt = ccsheet & "!" & ccsheet.Range("A79").Address(ReferenceStyle:=xlR1C1)
Set pvtCache = ActiveWorkbook.PivotCaches.Create( _
SourceType:=xlDatabase, _
SourceData:=SrcData)
Set pvt = pvtCache.CreatePivotTable( _
TableDestination:=StartPvt, _
TableName:="PivotTable1")
End Sub
Any help? Thanks
SrcData = srcSheet & "!" & Range("A1:V"& lrow).Address(ReferenceStyle:=xlR1C1)' this is the line that errors
– Eem Jee