Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code for Grouping Text Values in Pivotfield
it can definitely be done manually. It would be the code to do it that I am
looking for. Thanks "Dave Peterson" wrote in message ... I don't think you can group text values like this. Maybe you could add another helper column to your raw data and put a formula that "groups" the data for you. (Maybe a =vlookup() if you have lots of categories/groups.) Keith Young wrote: I have read the help and there is example code for Grouping numbers/date in a pivotfield. However, I am interested in grouping specific text values in a pivotfield which may not be in any specific order. For example, say a pivotfield has the following values: aaa bbb ccc ddd eee Using code, I would like to group aaa and ccc and call it GroupX; bbb and ddd would be grouped and called GroupY and eee would be in its own group called GroupZ. Can this be accomplished somehow using the group method (maybe using an array of the text values that are to be grouped)? Thanks, Keith -- Dave Peterson |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code for Grouping Text Values in Pivotfield
If you mean add the formula via code, you could do something like:
dim LastRow as long with activesheet lastrow = .cells(.rows.count,"A").end(xlup).row .range("j2:J" & lastcell).formula _ = "=vlookup(a2,sheet2!$a$1:$b$99,2,false)" end with You could add this before you did your pivottable (adjust the range/sheets accordingly). Then modify your pt code to include this column. (I usually record a macro to get my pivottables. I'm sure your recorded macro would work as well as my recorded macro <vbg.) Keith Young wrote: it can definitely be done manually. It would be the code to do it that I am looking for. Thanks "Dave Peterson" wrote in message ... I don't think you can group text values like this. Maybe you could add another helper column to your raw data and put a formula that "groups" the data for you. (Maybe a =vlookup() if you have lots of categories/groups.) Keith Young wrote: I have read the help and there is example code for Grouping numbers/date in a pivotfield. However, I am interested in grouping specific text values in a pivotfield which may not be in any specific order. For example, say a pivotfield has the following values: aaa bbb ccc ddd eee Using code, I would like to group aaa and ccc and call it GroupX; bbb and ddd would be grouped and called GroupY and eee would be in its own group called GroupZ. Can this be accomplished somehow using the group method (maybe using an array of the text values that are to be grouped)? Thanks, Keith -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Have the need to sort text code-values within same Excel cell | Excel Worksheet Functions | |||
Conditional Formatting - Code to colour 3+ text values differently | Excel Discussion (Misc queries) | |||
VB Script Code needed for Grouping Rows | Excel Discussion (Misc queries) | |||
Grouping Corresponding Values | Excel Discussion (Misc queries) | |||
Macro to change the PivotField to sum | Excel Discussion (Misc queries) |