-
Knowledge Base Approver
The King of Overkill!
VBAX Master
Hey there, sorry about the delay
I did have a great vacation, unfortunately it means I have a busier week this week, on top of some new work being thrown at me. But I'll gladly make some time to help you, I'm a sucker for a pretty face!
For your pivot table issue, this had me stumped for a few minutes.. I finally got it though (I use excel 2000 and the help files for the .Add on the pivotcaches is incorrect, thanks to a post on mrexcel.com I was able to figure it out). Here is a new Step 8 for you:
[vba]' Step 8 : Add New Worksheets For Each Group Name
For j = 0 To vGNCnt
vNewSheet = Left(Replace(Replace(Replace(Replace(Replace(Replace( _
Replace(vGroupNames(j), ":", ""), "\", ""), "\", ""), "?", "") _
, "*", ""), "[", ""), "]", ""), 31)
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = vNewSheet
For i = 0 To jUB
Cells(1, i + 1) = vArr(0, i)
Next 'i
r = 2
For i = 1 To iUB
If vArr(i, 3) = vGroupNames(j) Then
For c = 1 To jUB + 1
Cells(r, c) = vArr(i, c - 1)
Next 'c
r = r + 1
End If
Next 'i
ActiveSheet.UsedRange.Sort Key1:=Range("D2"), Header:=xlYes
pTableName = "PivotTable-" & vNewSheet
Range("G1").Select
'if you are using excel 2000, keep the .Address(0, 0) in here
' if you are using a newer version, you may have to take it out
ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
Range("A1", Cells(r - 1, c - 1)).Address(0, 0)) _
.CreatePivotTable TableDestination:=Range("G1"), TableName:=pTableName
ActiveSheet.PivotTables(pTableName).SmallGrid = False
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables(pTableName).PivotFields("Real Name")
.Orientation = xlDataField
.Position = 1
End With
Application.CommandBars("PivotTable").Visible = False
Columns.AutoFit
Next 'j[/vba]
Are you still having a problem with your Main sheet? If so, are you wanting it to go via the pivot table method like you have originally, or would you be open to a new way to do it?
Matt
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules