View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Matthew Herbert[_3_] Matthew Herbert[_3_] is offline
external usenet poster
 
Posts: 149
Default Group lines of data and subtotal

Peruanos72,

Using a PivotTable will be the least painful, and will utilize Excel's
existing functionality. The PivotTable allows you to keep your original
source data in tact and let you manipulate the source data through the
PivotTable's functionality. If you want VBA code to do something similar,
then I can create a sample, but you can reply as to whether or not you want
the VBA.

The steps below make a few basic assumptions:
(1) the user is using Excel 2007 (it is likely that the steps listed below
will be almost identical in Excel 2003; if I remember correctly, Excel 2003
has a bit more drag and drop to the actual table itself than 2007 has),
(2) the data set is the one listed in the thread and is anchored in cell A2
(i.e. the first "ABC" is in cell A2), and
(3) row 1 contains a heading name for each of the columns (for purposes of
illustration, I've labeled A1 as "Title" and H1 as "Amt" -- the other labels
are irrelevant to this example, but are necessary if plan on using the fields
in the PivotTable).

Perform the following steps:
(1) Select the data set (i.e. A1:H8)
(2) From the Ribbon, select the following: Insert | PivotTable | PivotTable
(3) Leave the default as "New Worksheet" or select "Existing Worksheet" -- I
selected "Existing Worksheet" and picked cell J1
(4) Select OK
(5) In "Choose fields to add to report:" check "Title"
(6) Drag and drop the "Amt" to the "Value" section; your table should now
show three entries: (1) ABC - 1048, (2) HER - 10681, and (3) KLE - 16945
(7) Right click the actual PivotTable and select the following: Filter |
Value Filters
(8) The "Value Filter" dialog box should show "Sum of Amt", "equals", and
"<blank". Change "equals" to "is greater than" and enter "10000" in the
"<blank" box.
(9) Click OK.

Your table should now show two entries: (1) HER - 10681, and (2) KLE -
16945. You now have a data set that is free of values less than 10000. Feel
free to add more fields to the data table. I hope this is helpful.

Best,

Matt

"Peruanos72" wrote:

Thanks Jen. I'm new to writing code and Matts suggestion worked well.
Below is what I've asked Mike.

Now what I'd like to do is remove the groups of data where
the subtotal is less than $10,000. I'm new to writing code but I believe I
can search "total" and use if then statements to determine of the subtotal is
less than
$10,000 but once I determine that how can I select the range of data above
and delete?


"Jen" wrote:

Two options come to mind:
1. Use jet to read in the data and use a query like "select sum(H) as
[mytotal] from [mytable] group by a, b, c, d, e, f, g"
2. Within Excel, keep an array of current values of a,b,c,d,e,f,g. If
any of the values change, dump out the value in the accumulator and
reset.

No sure if you need code. I am just typing as I am thinking.

Jenn


On Aug 25, 3:59 pm, Peruanos72
wrote:
I have multiple lines of data in columns A,B, C, D,E,F,G AND H where column H
contains a dollar value. The data in each column, except H is the same for
multiple rows and then the data in columns A,B, C, D,E,F,G changes. This
continues for multiple rows. What I need to do is somehow seperate the lines
of data into groups where the data in columns A,B, C, D,E,F,G are the same so
I can then subtotal column H for that group of data.

Example:

I need to subtotal the dollar value for ABC, HER and KLE
Note: The data will change from day to day so I can't simply search for a
particular value.

ABC 2009040 780312737 8 WAFRIJEN 6/4/2009 204984337001 $500.00
ABC 2009040 780312737 8 WAFRIJEN 6/4/2009 204984337001 $248.00
ABC 2009040 780312737 8 WAFRIJEN 6/4/2009 204984337001 $300.00
HER 2009041 780748728 8 522660V1 6/4/2009 571201170018 $5,896.00
HER 2009041 780748728 8 522660V1 6/4/2009 571201170018 $4,785.00
KLE 2009042 780546059 8 3469-1-7 6/2/2009 521779986001 $4,456.00
KLE 2009042 780546059 8 3469-1-7 6/2/2009 521779986001 $12,489.00

Thanks in advance!!