Link to home
Start Free TrialLog in
Avatar of willie108
willie108

asked on

vba macro for pivot table including "blank"

I am running the attached vba for creating a pivot table from the attached data. I don't know why it is including "blank" as one of the entries in the pivot table.
Sub makeRelativePivot2()
'
' makeRelativePivot2 Macro
'

'
  
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "perStockTweets!R1C1:R3926C7", Version:=xlPivotTableVersion14). _
        CreatePivotTable TableDestination:="", TableName:="PivotTable5" _
        , DefaultVersion:=xlPivotTableVersion14

    With ActiveSheet.PivotTables("PivotTable5").PivotFields("Date")
        .Orientation = xlRowField
        .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable5").AddDataField ActiveSheet.PivotTables( _
        "PivotTable5").PivotFields("Tweet ID"), "Sum of Tweet ID", xlSum
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveSheet.PivotTables("PivotTable5").PivotFields("Sum of Tweet ID").Function _
        = xlCount
End Sub

Open in new window

Anyone know about it?
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Hard to be sure without the data but I'd guess one of your key cells is blank.
Avatar of willie108
willie108

ASKER

Hello. I thought I attached the data. Let me try it again.
sample.csv
Hello. I attached the data in the previous post. I also tried to make a pivot table manually and did not get a blank row.
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. Will that be flexible? I want to use it on data for which I don't know the number of rows.
Great. Thanks.