Calculating # of days since last audit.

stronik814

New Member
Joined
Jan 22, 2014
Messages
5
I need to do the following but I'm a complete Excel novice when it comes to macros. I know the logic but don't know the syntax to write the macro. I was wondering if someone would be able to help me out.

-Thank you!


I'm trying to calculate Variable A for M1, the # of days since the last audit. Looking at the table below, from current date 11/7, the last audit was performed on 11/1. So 6 days since the last audit, so A = 6.

To do this, I was thinking of the following logic.

Search for today's date in column B.
Once found, set that variable to Q.
After, go over 2 columns right and select that value, let's say x.

If(x>=0, A = 0, else do the following: go up column D until x does not = blank.

Once x does not equal blank, go over 2 columns left and select that value.
Set that variable to W.

A = Q - W.


ABCDEF
1Today's Date
211/7/14
30 = No Leak
41 = Leaks
5
6
7# of days
8M1Variable A
9M2Variable B
10M3Variable C
11M4Variable D
12
13
14DateM1 Leak?
1510/31/140
1611/1/140
1711/2/14
1811/3/14
1911/4/14
2011/5/14
2111/6/14
2211/7/14

<TBODY>
</TBODY>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Forum statistics

Threads
1,216,366
Messages
6,130,194
Members
449,565
Latest member
excelqueenintraining

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