Looping and Summing

ajay1

New Member
Joined
Feb 1, 2016
Messages
15
Trying to sum values in excel sheet based on due date. Goal is to create a macro where user has to press "Command Button" and Macro do the following:

1. Enter a date
2. Check the date against all the dates in Column B (AKA Due Date Column)
- IF the due date is earlier than the date entered, sum the amount due, else, move to the next cell
3. Return the value of the total sum

So far i have this:
Sub ARSUM()
Dim dateEntry As Date
dateEntry = InputBox(“Enter a Date”)
#Selection.Value = status
ARSUM(2).Range(“h3”).value = dateEntry

I know at this point I am going to need some kind of loop. Help?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If I enter, 11/28/2014, what would be summed on your sheet? More specifically, what ranges need to be summed?
 
Upvote 0
If I enter, 11/28/2014, what would be summed on your sheet? More specifically, what ranges need to be summed?

specifically, the Due date range will be checked for the date and the "Open Balance" column will be summed as well. I plan on the user using modifying these columns a good amount so i thought about, instead of ranging it from the beginning of the first balance to the last cell in the column, maybe it could look for the last cell that has data in it?
 
Upvote 0
Yes, I have looked at SUMIF. Unfortunately, when I try to format it for the date condition, it does not adjust every time I set a different date
 
Upvote 0
But Michaelsmith559, something along the lines I was thinking like
LR = Cells(Rows.Count, "A").End(xlup).Row
 
Upvote 0
Yes, I have looked at SUMIF. Unfortunately, when I try to format it for the date condition, it does not adjust every time I set a different date

is the date you are entering a real date, or a text that looks like a dare? Test it with =ISNUMBER(cell-ref)
 
Upvote 0
Well I just read that the SUMIF function reads the cell as string, but what if I wanted to read it as a date?

Also, I tested the range, the test came out TRUE
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top