I need to add column based on two conditions using Excel 2003

S

SW

I'm looking to add totals that are associated with a specific date in column
A (say, 1/13); and a students name in column B (say, Harold). Once those two
conditions are met the formula would add the totals of the associated totals
found in column C and place that total in a cell in Column D. I'm using
Excel 2003.

Thanks much for any insight and expertise you may provide.
 
J

JLGWhiz

I expect you will need to post back, because your destination
cell in column D was not specific. This code puts the total
in the next available cell into column D which does not relate
it to its origin. It was also assumed that the values being
totaled contain decimal values, if not, a place is marked for
changing the data type to Long instead of double. It will run
either way and the difference is negligible for this purpose.

Sub stitute()
Dim dt As String, nm As String, lr As Long
Dim ColCval as Double '<<<If no decimals change to Long
lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
dt = InputBox("Enter a date to search", "Date")
nm = InputBox("Enter a name to search", "Name")
For Each c In ActiveSheet.Range("A2:A" & lr)
If Not c Is Nothing Then
If c.Value = dt And c.Offset(0, 1).Value _
= rm Then
ColCval = ColCval + ColCval
End If
Next
ActiveSheet.Cells(Rows.Count, 4).End(xlup) = ColCval
End Sub
 
S

SW

Thanks much for your reply. I think I asked for too much. I was mistaken in
asking for 'programming' help. I'm actually looking for a fomuala that loos
at data in one Work Sheet and transfers the sum to a cell in another work
sheet: all within the same Workbook. I've actually got a working formual
using Excel 2007 but the school I'm working at only has Excel 2003 so I need
to rewrite the formuala.
The following is the Excel 2007 formula I'm using:

SUMIFS('2003 StarWords.xlsx'!GrandTotal,'2003
StarWords.xlsx'!WeekOf,"1/13",'2003 StarWords.xlsx'!Name,"Abby")

I hate to bother you with this but if you can help it would be most
appreciated.

With Much Respect.

Steve
 
J

JLGWhiz

Why don't you go ahead and post it in the Worksheet functions group. Someone
there who is more familiar with your problem will help you. Just include
your current formula and explain what you want to accomplish. Outside the
file difference in file extensions, I don't know that there is a lot of
difference in the structure of the formula itself.
 
S

SW

--
SW


JLGWhiz said:
Why don't you go ahead and post it in the Worksheet functions group. Someone
there who is more familiar with your problem will help you. Just include
your current formula and explain what you want to accomplish. Outside the
file difference in file extensions, I don't know that there is a lot of
difference in the structure of the formula itself.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top