Home

I need a cell to use a simple formula if date conditions are met

%3CLINGO-SUB%20id%3D%22lingo-sub-463067%22%20slang%3D%22en-US%22%3EI%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463067%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20trying%20to%20plan%20for%20large%20expenses%20as%20equipment%20reaches%20it's%20lifespan.%26nbsp%3B%20I%20want%20to%20take%20a%20dynamic%2015%20year%20span%2C%20and%20if%20a%3A%3C%2FP%3E%3CP%3Edate%20of%20purchase%20c3%20plus%20expected%20lifespan%20i3%20is%20more%20than%20a%20given%20year%20k3%20to%20z3%2C%20I%20want%20o3%20(in%20the%20case%20of%20the%20end%20of%20service%20date%20for%20row%203)%20to%20populate%20with%20a%20purchase%20price%20d3*e3%20quantity%20owned%20to%20tell%20us%20we%20need%20to%20plan%20to%20budget%20in%202023%20for%20%2431455.%3C%2FP%3E%3CP%3EI%20got%20conditional%20formatting%20to%20work%20for%20applying%20Red%2C%20yellow%2C%20green%20for%20due%20dates%20in%20the%20J%20column.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E**I%20am%20aware%20of%20how%20that%20particular%20math%20will%20be%20flawed%20based%20on%20the%20spreadsheet%20given%20to%20me%20since%20it%20was%20%2431455%20for%203%20of%20them%20on%20the%20sheet%2C%20but%20I%20am%20dealing%20with%20what%20was%20handed%20to%20me%20and%20I%20will%20fix%20that%20math%20later%2C%20so%20please%20ignore%20that%20part%20if%20you%20see%20it%20in%20the%20picture.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F109164i1DB820E23020ECD4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22excel.jpg%22%20title%3D%22excel.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-463067%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-463151%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463151%22%20slang%3D%22en-US%22%3EI%20advise%20you%20to%20refrain%20from%20using%20conditional%20formatting%20as%20a%20basis%20of%20whether%20a%20condition%20exists.%20I%20will%20scrutinize%20your%20data%20in%20a%20little%20while%20to%20determine%20my%20suggested%20course%20of%20action%20you%20should%20take.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-463194%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463194%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F322206%22%20target%3D%22_blank%22%3E%40InOverMyHead%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20understand%20you%20want%20a%20formula%20in%20cells%20K3%20to%20Z3%20that%20calculates%20a%20number%20if%20the%20year%20in%20row%202%20is%20greater%20than%20the%20service%20date%20year%20plus%20lifespan.%20I%20don't%20see%20any%20number%20in%20column%20I%20in%20your%20screenshot%2C%20but%20I%20think%20the%20following%20formula%20should%20do%20what%20you%20describe.%20Put%20the%20formula%20into%20K3%20and%20copy%20to%20the%20right.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3DIF(YEAR(%24C3)%2B%24I3%2B1%3DK%242%2C%24D3*%24E3%2C0)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-463202%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463202%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3BWhy%3F%20That%20is%20what%20conditional%20formatting%20is%20made%20for.%20Use%20formatting%20if%20a%20condition%20is%20true.%20That's%20the%20point%20of%20conditional%20formatting.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-463284%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463284%22%20slang%3D%22en-US%22%3EI%20personally%20believe%20that%20conditional%20formatting%20should%20be%20applied%20to%20reports%2C%20not%20on%20data%2C%20because%20such%20formatting%20can%20only%20accept%20a%20fixed%20range%2C%20never%20a%20dynamic%20range.%20Reports%20are%20limited%20to%20a%20certain%20range%2C%20and%20can%20therefore%20be%20conveniently%20applied%20with%20conditional%20formatting.%3CBR%20%2F%3EConversely%2C%20data%20can%20extend%20to%20an%20indefinite%20range%2C%20thereby%20requiring%20a%20modification%20of%20the%20conditional%20formatting%20range%2C%20if%20and%20when%20such%20formatting%20is%20desired%20to%20be%20applied%20to%20the%20extended%20range.%3CBR%20%2F%3EWith%20all%20due%20respect%20to%20you%2C%20I%20hereby%20stand%20ready%20to%20be%20corrected%2C%20if%20or%20when%20you%20can%20prove%20falsity%20hereof.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-463483%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-463483%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%20%2C%20IMHO%2C%20conditional%20formatting%20in%20many%20cases%20is%20clever%20enough%20to%20expand%20the%20range%20dynamically%20while%20you%20are%20adding%20the%20data.%20Apply%20it%20to%20entire%20column%20is%20also%20costs%20practically%20nothing.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-464251%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-464251%22%20slang%3D%22en-US%22%3EReplacement%20of%20equipment%20occurs%20when%20it%20reaches%20the%20end%20of%20its%20service%20life%2C%20not%20after%20one%20year%20from%20such%20end%3B%20otherwise%2C%20no%20such%20equipment%20would%20be%20available%20for%20use%20within%20that%20one%20year%20period.%3CBR%20%2F%3EPremised%20on%20the%20foregoing%2C%20the%20formula%20in%20K3%2C%20copied%20to%20the%20right%2C%20is%3A%3CBR%20%2F%3E%3D((YEAR(%24C3)%2B%24I3)%3DK%242)*(%24D3*%24E3)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-472021%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-472021%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7724%22%20target%3D%22_blank%22%3E%40Ingeborg%20Hawighorst%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20all%20for%20your%20input.%26nbsp%3B%20After%20trial%20of%20both%2C%20I%20found%20the%20one%20that%20Twifoo%20provided%20to%20work.%26nbsp%3B%20Ineborg%2C%20yours%20worked%20also%2C%20but%26nbsp%3Binserted%20the%20budget%20into%20the%20following%20year.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20are%20all%20wonderful.%26nbsp%3B%20Thank%20you%20for%20your%20assistance.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-473366%22%20slang%3D%22en-US%22%3ERe%3A%20I%20need%20a%20cell%20to%20use%20a%20simple%20formula%20if%20date%20conditions%20are%20met%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-473366%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F322206%22%20target%3D%22_blank%22%3E%40InOverMyHead%3C%2FA%3E%26nbsp%3Bthe%20formula%20I%20suggested%20puts%20the%20amount%20in%20the%20following%20year%20because%20of%20the%20%2B1%20in%20the%20formula.%20Remove%20it%20if%20you%20want.%20It's%20how%20I%20understood%20the%20requirement.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETwifoo's%20formula%20is%20clever%20and%20shorter%2C%20but%20unless%20you%20really%20understand%20how%20it%20works%2C%20you%20may%20find%20it%20hard%20to%20maintain.%20An%20IF%20statement%20is%20a%20lot%20clearer%20than%20a%20multiplication%20with%20a%20comparison.%26nbsp%3B%20I%20prefer%20to%20keep%20it%20simple%20and%20easier%20to%20understand.%3C%2FP%3E%3C%2FLINGO-BODY%3E
InOverMyHead
New Contributor

I am trying to plan for large expenses as equipment reaches it's lifespan.  I want to take a dynamic 15 year span, and if a:

date of purchase c3 plus expected lifespan i3 is more than a given year k3 to z3, I want o3 (in the case of the end of service date for row 3) to populate with a purchase price d3*e3 quantity owned to tell us we need to plan to budget in 2023 for $31455.

I got conditional formatting to work for applying Red, yellow, green for due dates in the J column.

 

 

**I am aware of how that particular math will be flawed based on the spreadsheet given to me since it was $31455 for 3 of them on the sheet, but I am dealing with what was handed to me and I will fix that math later, so please ignore that part if you see it in the picture.excel.jpg

8 Replies
I advise you to refrain from using conditional formatting as a basis of whether a condition exists. I will scrutinize your data in a little while to determine my suggested course of action you should take.

@InOverMyHead 

 

I understand you want a formula in cells K3 to Z3 that calculates a number if the year in row 2 is greater than the service date year plus lifespan. I don't see any number in column I in your screenshot, but I think the following formula should do what you describe. Put the formula into K3 and copy to the right. 

 

=IF(YEAR($C3)+$I3+1=K$2,$D3*$E3,0)

 

 

Highlighted

@Twifoo Why? That is what conditional formatting is made for. Use formatting if a condition is true. That's the point of conditional formatting. 

I personally believe that conditional formatting should be applied to reports, not on data, because such formatting can only accept a fixed range, never a dynamic range. Reports are limited to a certain range, and can therefore be conveniently applied with conditional formatting.
Conversely, data can extend to an indefinite range, thereby requiring a modification of the conditional formatting range, if and when such formatting is desired to be applied to the extended range.
With all due respect to you, I hereby stand ready to be corrected, if or when you can prove falsity hereof.

@Twifoo , IMHO, conditional formatting in many cases is clever enough to expand the range dynamically while you are adding the data. Apply it to entire column is also costs practically nothing.

Replacement of equipment occurs when it reaches the end of its service life, not after one year from such end; otherwise, no such equipment would be available for use within that one year period.
Premised on the foregoing, the formula in K3, copied to the right, is:
=((YEAR($C3)+$I3)=K$2)*($D3*$E3)

@Twifoo @Sergei Baklan @Ingeborg Hawighorst 

Thank you all for your input.  After trial of both, I found the one that Twifoo provided to work.  Ineborg, yours worked also, but inserted the budget into the following year.

 

You are all wonderful.  Thank you for your assistance.

@InOverMyHead the formula I suggested puts the amount in the following year because of the +1 in the formula. Remove it if you want. It's how I understood the requirement.

 

Twifoo's formula is clever and shorter, but unless you really understand how it works, you may find it hard to maintain. An IF statement is a lot clearer than a multiplication with a comparison.  I prefer to keep it simple and easier to understand.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
22 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies