Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Have the need to sort text code-values within same Excel cell A.X M.D Excel Worksheet Functions 2 December 3rd 09 07:26 PM
Conditional Formatting - Code to colour 3+ text values differently AK9955 Excel Discussion (Misc queries) 3 November 9th 09 06:11 PM
VB Script Code needed for Grouping Rows Abhi_Rise Excel Discussion (Misc queries) 0 February 19th 08 02:01 PM
Grouping Corresponding Values Mark Hughes Excel Discussion (Misc queries) 3 May 1st 07 04:59 PM
Macro to change the PivotField to sum Vick Excel Discussion (Misc queries) 3 December 21st 05 10:34 PM


All times are GMT +1. The time now is 12:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"