VBA code to group columns into days in Excel 2010 (over 8000 columns)

epamias

New Member
Joined
May 18, 2016
Messages
14
All,

I have this code that can create a pivot table for my monthly data but when I try to modify and use it for my 8 week trend data it gives me an error that I cannot do it because I am over 8000 columns. I need to group weekending into days, then I will be able to use the code for my 8 week trend. By the way I add a filter which on my data sheet any tickets closed within 8 weeks gives me the word valid at the end of the row. So I filter on that so I can get all tickets closed in 8 weeks. Unfortunately I did not at that to this code. I would need help doing that. See code below....

Code:
Sub CreatePivot()
    ' Creates a PivotTable report from the table on Sheet1
    ' by using the PivotTableWizard method with the PivotFields
    ' method to specify the fields in the PivotTable.
    Dim objTable As PivotTable, objField As PivotField
    
    ' Select the sheet and first cell of the table that contains the data.
    ActiveWorkbook.Sheets("Closed Data").Select
    Range("A1").Select
    
    ' Create the PivotTable object based on the Closed data on Sheet1.
    Set objTable = Sheet1.PivotTableWizard
    
    ' Specify row and column fields.
    Set objField = objTable.PivotFields("Assigned To")
    objField.Orientation = xlRowField
    Set objField = objTable.PivotFields("Weekending")
    objField.Orientation = xlColumnField
    
    ' Specify a data field with its summary
    ' function and format.
    Set objField = objTable.PivotFields("Number")
    objField.Orientation = xlDataField
    'objField.Function = xlSum
    'objField.NumberFormat = "$ #,##0"
    
    ' Specify a page field.
    'Set objField = objTable.PivotFields("GENDER")
    'objField.Orientation = xlPageField
    
    ' Preview the new PivotTable report.
    'ActiveSheet.PrintPreview
    
    ' Prompt the user whether to delete the PivotTable.
    'Application.DisplayAlerts = False
    'If MsgBox("Delete the PivotTable?", vbYesNo) = vbYes Then
     '   ActiveSheet.Delete
    'End If
    'Application.DisplayAlerts = True
 End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I REM'd out things I do not need in the code but did not want to delete them because they may be useful to me.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

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