Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum Values when Duplicate ID Exists


I need to create a macro to search down Column A and if their is for
example 3 duplicates to add there 3 values (from column d) together.

For example if it searched the below piece of data, it would see 1250
is listed 3 times, so it would move over to column d and sum 417+42+250
and place the total in column E on the last row of the duplicates.

COL-A ___ COL-B__ COL-C ______________ COL-D __ COL-E
1239 ____ 14 __ COMPUTER HARDWARE ______ 0 ______
1250 ____ 10 __ COURSES - TRAINING ______ 417 ______
1250 ____ 12 __ COURSES - TRAINING ______ 42 ______
1250 ____ 14 __ COURSES - TRAINING ______ 250 __ 709
1271 ____ 10 __ CUST. DUTY & NON-RECOV __ 8333 __

I have also attached a tab delimited version in .txt format.


+-------------------------------------------------------------------+
|Filename: budgets.txt |
|Download: http://www.excelforum.com/attachment.php?postid=5109 |
+-------------------------------------------------------------------+

--
sealanes
------------------------------------------------------------------------
sealanes's Profile: http://www.excelforum.com/member.php...o&userid=36834
View this thread: http://www.excelforum.com/showthread...hreadid=565452

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Sum Values when Duplicate ID Exists

Sub Test()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To iLastRow
If Cells(i, "A").Value = Cells(i - 1, "A").Value Then
If Cells(i, "A").Value < Cells(i + 1, "A").Value Then
Cells(i, "E").Value = Application.SumIf( _
Columns(1), Cells(i, "A").Value, Columns(4))
End If
End If
Next i

End Sub

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"sealanes" wrote in
message ...

I need to create a macro to search down Column A and if their is for
example 3 duplicates to add there 3 values (from column d) together.

For example if it searched the below piece of data, it would see 1250
is listed 3 times, so it would move over to column d and sum 417+42+250
and place the total in column E on the last row of the duplicates.

COL-A ___ COL-B__ COL-C ______________ COL-D __ COL-E
1239 ____ 14 __ COMPUTER HARDWARE ______ 0 ______
1250 ____ 10 __ COURSES - TRAINING ______ 417 ______
1250 ____ 12 __ COURSES - TRAINING ______ 42 ______
1250 ____ 14 __ COURSES - TRAINING ______ 250 __ 709
1271 ____ 10 __ CUST. DUTY & NON-RECOV __ 8333 __

I have also attached a tab delimited version in .txt format.


+-------------------------------------------------------------------+
|Filename: budgets.txt |
|Download: http://www.excelforum.com/attachment.php?postid=5109 |
+-------------------------------------------------------------------+

--
sealanes
------------------------------------------------------------------------
sealanes's Profile:

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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sum Values when Duplicate ID Exists


Thanks for that mate, worked first time.


--
sealanes
------------------------------------------------------------------------
sealanes's Profile: http://www.excelforum.com/member.php...o&userid=36834
View this thread: http://www.excelforum.com/showthread...hreadid=565452

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
duplicate values CandiC Excel Worksheet Functions 2 February 18th 10 07:43 PM
Return Value that exists more than all other values AdamE Excel Worksheet Functions 9 November 20th 07 10:07 PM
Duplicate Values Lost in Microbiology Excel Discussion (Misc queries) 2 May 10th 07 09:09 PM
Duplicate values Tom Ogilvy Excel Programming 0 July 20th 03 04:43 PM
Duplicate values Bob Phillips[_5_] Excel Programming 0 July 20th 03 04:21 PM


All times are GMT +1. The time now is 08:39 AM.

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"