Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Group values and sum using loop


Need some help on this one. I need to do the following using probably
For...Next loop:
Preface: There are two columns (H,I) that has values. Column H ha
dollar amounts and Column I has an identifier number (both formatted a
number).

One identifier number could comprise several dollar amounts. In othe
words, 10 rows could have different dollar amounts in column H, but al
have the same identfier number of "5".

1. Iterate down and capture the first identifier
2. Iterate down and capture the dollar amounts assigned to tha
identifier
3. Insert a row and enter the sum amount in column H.
4. Move to the next row (which should have the next identifier) an
repeat.

Example:

Col H, Col I
H2 = $55.00, I2 = 5
H3 = $25.00, I3 = 5
<Insert Row: H4 = SUM(H2:H3)
H5 = $35.00, I5 = 7
H6 = $15.00, I6 = 7
<Insert Row: H7 = SUM(H5:H6)

Thanks is advance for the expertise!

--
mthoma
-----------------------------------------------------------------------
mthomas's Profile: http://www.excelforum.com/member.php...fo&userid=2564
View this thread: http://www.excelforum.com/showthread.php?threadid=39336

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Group values and sum using loop

Data=Subtotal

it does it for you.

--
Regards,
Tom Ogilvy


"mthomas" wrote in
message ...

Need some help on this one. I need to do the following using probably a
For...Next loop:
Preface: There are two columns (H,I) that has values. Column H has
dollar amounts and Column I has an identifier number (both formatted as
number).

One identifier number could comprise several dollar amounts. In other
words, 10 rows could have different dollar amounts in column H, but all
have the same identfier number of "5".

1. Iterate down and capture the first identifier
2. Iterate down and capture the dollar amounts assigned to that
identifier
3. Insert a row and enter the sum amount in column H.
4. Move to the next row (which should have the next identifier) and
repeat.

Example:

Col H, Col I
H2 = $55.00, I2 = 5
H3 = $25.00, I3 = 5
<Insert Row: H4 = SUM(H2:H3)
H5 = $35.00, I5 = 7
H6 = $15.00, I6 = 7
<Insert Row: H7 = SUM(H5:H6)

Thanks is advance for the expertise!!


--
mthomas
------------------------------------------------------------------------
mthomas's Profile:

http://www.excelforum.com/member.php...o&userid=25649
View this thread: http://www.excelforum.com/showthread...hreadid=393365



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Group values and sum using loop

Take a look at Data-Subtotal as a built in Excel feature. It might be
easier than writing code.

--
Cheers
Nigel



"mthomas" wrote in
message ...

Need some help on this one. I need to do the following using probably a
For...Next loop:
Preface: There are two columns (H,I) that has values. Column H has
dollar amounts and Column I has an identifier number (both formatted as
number).

One identifier number could comprise several dollar amounts. In other
words, 10 rows could have different dollar amounts in column H, but all
have the same identfier number of "5".

1. Iterate down and capture the first identifier
2. Iterate down and capture the dollar amounts assigned to that
identifier
3. Insert a row and enter the sum amount in column H.
4. Move to the next row (which should have the next identifier) and
repeat.

Example:

Col H, Col I
H2 = $55.00, I2 = 5
H3 = $25.00, I3 = 5
<Insert Row: H4 = SUM(H2:H3)
H5 = $35.00, I5 = 7
H6 = $15.00, I6 = 7
<Insert Row: H7 = SUM(H5:H6)

Thanks is advance for the expertise!!


--
mthomas
------------------------------------------------------------------------
mthomas's Profile:

http://www.excelforum.com/member.php...o&userid=25649
View this thread: http://www.excelforum.com/showthread...hreadid=393365



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Group values and sum using loop


Yea, I just decided to record a macro for the Sub Totals feature and
tweak it a bit and it does the job. Because the number of rows vary,
I'm using the lastRow variable to make it dynamic.

Dim lastRow
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

Range("I" & beginRow & "").Select
Selection.Subtotal GroupBy:=9, Function:=xlSum,
TotalList:=Array(8), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True

Thanks all!


--
mthomas
------------------------------------------------------------------------
mthomas's Profile: http://www.excelforum.com/member.php...o&userid=25649
View this thread: http://www.excelforum.com/showthread...hreadid=393365

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
How can I loop through a the values in multiple rows EMarre Excel Discussion (Misc queries) 6 May 13th 10 01:50 PM
Assign Cell Values without a Loop BHatMJ Excel Discussion (Misc queries) 4 May 29th 08 04:26 PM
Group values Remote Desktop Connection hotkey Excel Worksheet Functions 5 October 2nd 05 05:01 AM
sum values in a data group BigTim Excel Worksheet Functions 1 September 29th 05 03:59 AM
loop through a certain group of worksheets only Chris M Excel Programming 1 July 1st 05 01:02 AM


All times are GMT +1. The time now is 04:17 PM.

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

About Us

"It's about Microsoft Excel"