Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Sum values based on criteria in another column


I can't seem to visualize what you really want so, if desired, send your
file to my address below along with a clear explanation and before/after
examples. Also, include a snippet of this msg.


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Derek Johansen" wrote in message
...
Okay, i figured out where to implement the VBA Script, but now my question
is
What does the line mc = mc + cells(i, "J") do? Also, how difficult would
it
be to implement this for every row? What i mean is: After it checks all
the
values against Cell C2 and sums the total, it then checks the remaining
values against C3, and then against C4, etc...

"Derek Johansen" wrote:

Okay, and now since I am a little slow, and haven't done much of anything
in
excel, is there a good resource to actually learning how to implement
that
bit of code into excel? I don't know really how to begin writing a
program/script for excel :-/

"Don Guillett" wrote:

Should do it

Sub Addupifmatch()
For i = Cells(Rows.Count, "c").End(xlUp).Row To 3 Step -1
If Cells(i, "c") = Range("c2") Then
mc = mc + Cells(i, "J")
Rows(i).Delete
End If
Next
MsgBox mc
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Derek Johansen" <Derek
wrote in
message
...
Essentially, what I am looking to do is go through a sheet and say:
If value of C3 matches value of C2, then add J2+J3, and then delete
row 3.
If i was familiar with excel, or knew how to script/program in excel,
i
would
think it would be something like this (basic idea...)

n == 3
DO While (n < Number_of_rows)
DO While (Cn == C2)
J2 == J2 + Jn
Delete Row 3
End Do
n == n+1
END DO

^^ That would be check to see if the contents of column C matched the
contents of C2, and if they did, would sum the J column values in J2.
I
would then have more code to check to see if any of the values of
column C
matched the new value in C3, and would combine all J column values
into
J3.
Then check C4 and sum into J4, C5 sum J's into J5... Etc. All the
way
through C(number of rows) into J(number of rows)

It's been a while since I did any real programming, and the only
language
i
even know is fortran, so sorry if that code is hard to follow... Any
help
would be very much appreciated!!!



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
Filter duplicates based on criteria / column values phillr Excel Discussion (Misc queries) 0 April 9th 10 09:13 PM
Sum of values based on different criteria Irene Excel Discussion (Misc queries) 4 November 19th 08 11:17 PM
Looking up values based on two criteria LauriS Excel Worksheet Functions 8 August 24th 07 02:30 PM
Need to add values based on three other criteria Jonathan[_14_] Excel Programming 2 August 31st 06 11:10 AM
summing values in a data table based on criteria in another column Dave F Excel Worksheet Functions 7 August 26th 06 04:36 PM


All times are GMT +1. The time now is 03:36 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"