Home

How to exclude cells that contains formula from the range of cells in a LOOKUP function

%3CLINGO-SUB%20id%3D%22lingo-sub-501992%22%20slang%3D%22en-US%22%3EHow%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-501992%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20currently%20preparing%20a%20payment%20milestone%20template%20which%20also%20records%20the%20last%2Flatest%20date%20of%20payment.%20I%20used%20the%20this%20formula%20to%20do%20just%20that%2C%20%3DLOOKUP%20(2%2C1%2F%20(J4%3ALN4%26lt%3B%26gt%3B%22%22%2C%24J%242%3A%24LN%242)).%20But%20the%20problem%20starts%20when%20I%20added%20columns%20to%20get%20the%20SUM%20for%20each%20activity%20per%20month.%20I%20wanted%20to%20know%20if%20there%20is%20a%20condition%20that%20I%20can%20use%20to%20exclude%20cells%20with%20a%20formula%20on%20them.%20In%20the%20first%20activity%20%22G2-1090%22%2C%20I%20have%20deleted%20the%20SUM%20formula%20at%20the%20end%20of%20each%20month%20and%20the%20Last%20Paid%20Date%20column%20shows%20the%20last%20date%20of%20payment%20which%20is%20March%204.%20But%20since%20I%20wanted%20to%20get%20the%20sum%20per%20month%20I%20added%20a%20formula%20at%20the%20end%20of%20each%20month%20to%20calculate%20the%20total%20payment%20per%20activity%20per%20month.%20I%20have%20attached%20the%20template%20for%20reference.%20I%20hope%20someone%20could%20give%20me%20an%20advice%2Fsolution%20in%20this%20problem.%20Thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-501992%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELOOKUP%20FUNCTION%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Erange%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-502114%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-502114%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330179%22%20target%3D%22_blank%22%3E%40MrNobody%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi!%3C%2FP%3E%3CP%3EMaybe%20I%20can%20help%20you%2C%20but%20I%20need%20to%20understand%20your%20problem%20better.%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%20to%20calculate%20intermediate%20sums%20whose%20results%20should%20not%20be%20caught%20in%20the%20final%20sum%2C%20you%20can%20try%20the%20SUBTOTAL%20formula.%3C%2FP%3E%3CP%3EUse%20the%20SUBTOTAL%20at%20the%20end%20of%20each%20month%2C%20and%20then%20use%20SUBTOTAL%20at%20the%20end%20of%20the%20year%20or%20the%20quarter.%20In%20the%20last%20SUBTOTAL%20formula%2C%20even%20if%20you%20include%20the%20cells%20that%20have%20the%20subtotals%20for%20each%20month%2C%20those%20will%20be%20ignored%20and%20not%20included%20in%20the%20final%20sum.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20SUBTOTAL%20formula%20allows%20you%20to%20do%20other%20things%20different%20than%20SUM.%20To%20do%20sum%2C%20the%20first%20parameter%20is%209.%3C%2FP%3E%3CP%3E%3DSUBTOTAL(9%2CG5%3AI5)%20calculates%20the%20sum%20of%20cells%20G5%20to%20G15.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20not%20sure%20if%20this%20is%20what%20you%20are%20looking%20for.%20Please%20let%20me%20know%20how%20it%20goes.%20Good%20luck!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-502119%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-502119%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20your%20reply%20and%20your%20suggestion%20of%20using%20SUBTOTAL%20will%20definitely%20be%20added%20to%20the%20template.%20My%20aim%20is%20for%20the%20%22Last%20Paid%20Date%20-%20Column%20G%22%26nbsp%3B%20to%20return%20the%20last%20date%20of%20payment%20for%20the%20activity%20from%20the%20months%20to%20the%20right%20i.e.%20when%20there%20are%202%20or%203%20payment%20dates%20for%20the%20activity%2C%20it%20will%20return%20the%20last%20date%20only.%20LOOKUP%20function%20seems%20do%20this%20at%20first%20but%20when%20I%20added%20the%20SUM%20column%20per%20month%2C%20it%20doesn't%20work%20anymore%20I%20guess%20because%20in%20the%20SUM%20column%20there%20is%20no%20dates.%20%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-502153%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-502153%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330179%22%20target%3D%22_blank%22%3E%40MrNobody%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20the%20following%3A%20in%20G5%20enter%20the%20formula%3A%3C%2FP%3E%3CP%3E%3DMAX((ISNUMBER(J4%3ALN4))*(J2%3ALN2))%3C%2FP%3E%3CP%3EInstead%20of%20hitting%20enter%2C%20hit%20CTRL%2BSHFT%2BENTER.%3C%2FP%3E%3CP%3Eyou%20should%20get%20curly%20brackets%20at%20the%20beginning%20and%20the%20end%20of%20the%20formula%20like%20in%20the%20picture.%3C%2FP%3E%3CP%3Eremember%2C%20if%20you%20come%20back%20to%20the%20cell%20to%20edit%20this%20formula%2C%20you%20always%20need%20to%20hit%20those%203%20keys.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20770px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F111059i9D3B2DB3961DBA78%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22MrNobody.JPG%22%20title%3D%22MrNobody.JPG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20know%20if%20this%20solves%20your%20problem.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-502215%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-502215%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BThis%20is%20great%20stuff%2C%20finally%20it%20works%20!!%3C%2FP%3E%3CP%3EThe%20remaining%20problem%20is%20if%20there%20is%20no%20data%20in%20the%20row%2C%20it%20still%20returns%20a%20date%2C%20I%20hope%20you%20can%20help%20me%20solve%20this%20one.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20again%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-505199%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-505199%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330179%22%20target%3D%22_blank%22%3E%40MrNobody%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20fact%2C%20just%20realized%20that%20the%20ISNUMBER%20part%20does%20not%20well%20here.%20It%20was%20meant%20to%20disregard%20the%20formula%20cells%20but%20does%20do%20the%20intended%20job.%20In%20this%20case%2C%20we%20don't%20need%20it%20anyway%20because%20the%20columns%20with%20formulas%20are%20empty%20in%20row%202.%20If%20you%20keep%20that%20like%20that%2C%20you%20can%20use%20the%20formula%3A%3C%2FP%3E%3CP%3E%3DIF(SUM(J4%3ALN4)%3D0%2C%22%22%2CMAX(((J4%3ALN4%26gt%3B0))*(%24J%242%3A%24LN%242)))%20and%20hit%20C%2BS%2BE.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOr%2C%20if%20you%20need%20to%20write%20on%20row%202%20in%20the%20cells%20of%20columns%20with%20the%20subtotals%2C%20you%20can%20use%20the%20following%3A%3C%2FP%3E%3CP%3E%3DIF(SUM(J4%3ALN4)%3D0%2C%22%22%2C%3CBR%20%2F%3EMAX(%3CBR%20%2F%3ENOT(ISFORMULA(J4%3ALN4))*%3CBR%20%2F%3E(J4%3ALN4%26gt%3B0)%3CBR%20%2F%3E*(%24J%242%3A%24LN%242)%3CBR%20%2F%3E)%3CBR%20%2F%3E)%3C%2FP%3E%3CP%3Eand%20hit%20C%2BS%2BE.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20believe%20this%20works.%20Please%20let%20me%20know.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-505417%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-505417%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F330179%22%20target%3D%22_blank%22%3E%40MrNobody%3C%2FA%3E%26nbsp%3B%2C%20as%20variant%20you%20may%20expand%20your%20LOOKUP%20with%20one%20more%20filter%3C%2FP%3E%0A%3CPRE%3E%3DIFERROR(LOOKUP(2%2C1%2F(J4%3ALN4%26lt%3B%26gt%3B%22%22)%2F((%24J%241%3A%24LN%241%3D%22%22))%2C%24J%242%3A%24LN%242)%2C%22%22)%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-507522%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-507522%22%20slang%3D%22en-US%22%3ENice%20one%2C%20%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!%20As%20usual.%20%3B-)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-507558%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-507558%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%2C%20thank%20you%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-522540%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-522540%22%20slang%3D%22en-US%22%3E%3CP%3E%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%2F302344%22%20target%3D%22_blank%22%3E%40Celia_Alves%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20guys%20for%20the%20big%20help%20means%20a%20lot%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-525045%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20exclude%20cells%20that%20contains%20formula%20from%20the%20range%20of%20cells%20in%20a%20LOOKUP%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-525045%22%20slang%3D%22en-US%22%3EYou're%20welcome!%20Good%20luck%20with%20your%20projects.%3C%2FLINGO-BODY%3E
MrNobody
Occasional Contributor

Hello,

 

I am currently preparing a payment milestone template which also records the last/latest date of payment. I used the this formula to do just that, =LOOKUP (2,1/ (J4:LN4<>"",$J$2:$LN$2)). But the problem starts when I added columns to get the SUM for each activity per month. I wanted to know if there is a condition that I can use to exclude cells with a formula on them. In the first activity "G2-1090", I have deleted the SUM formula at the end of each month and the Last Paid Date column shows the last date of payment which is March 4. But since I wanted to get the sum per month I added a formula at the end of each month to calculate the total payment per activity per month. I have attached the template for reference. I hope someone could give me an advice/solution in this problem. Thank you

10 Replies

@MrNobody 

Hi!

Maybe I can help you, but I need to understand your problem better. 

If you want to calculate intermediate sums whose results should not be caught in the final sum, you can try the SUBTOTAL formula.

Use the SUBTOTAL at the end of each month, and then use SUBTOTAL at the end of the year or the quarter. In the last SUBTOTAL formula, even if you include the cells that have the subtotals for each month, those will be ignored and not included in the final sum. 

 

The SUBTOTAL formula allows you to do other things different than SUM. To do sum, the first parameter is 9.

=SUBTOTAL(9,G5:I5) calculates the sum of cells G5 to G15.

 

I am not sure if this is what you are looking for. Please let me know how it goes. Good luck!

 

 

 

@Celia_Alves 

 

Thank you for your reply and your suggestion of using SUBTOTAL will definitely be added to the template. My aim is for the "Last Paid Date - Column G"  to return the last date of payment for the activity from the months to the right i.e. when there are 2 or 3 payment dates for the activity, it will return the last date only. LOOKUP function seems do this at first but when I added the SUM column per month, it doesn't work anymore I guess because in the SUM column there is no dates.  

@MrNobody 

Try the following: in G5 enter the formula:

=MAX((ISNUMBER(J4:LN4))*(J2:LN2))

Instead of hitting enter, hit CTRL+SHFT+ENTER.

you should get curly brackets at the beginning and the end of the formula like in the picture.

remember, if you come back to the cell to edit this formula, you always need to hit those 3 keys.

 

MrNobody.JPG

 

Let me know if this solves your problem.

 

@Celia_Alves

 

 This is great stuff, finally it works !!

The remaining problem is if there is no data in the row, it still returns a date, I hope you can help me solve this one.

 

Thank you again 

@MrNobody 

In fact, just realized that the ISNUMBER part does not well here. It was meant to disregard the formula cells but does do the intended job. In this case, we don't need it anyway because the columns with formulas are empty in row 2. If you keep that like that, you can use the formula:

=IF(SUM(J4:LN4)=0,"",MAX(((J4:LN4>0))*($J$2:$LN$2))) and hit C+S+E.

 

Or, if you need to write on row 2 in the cells of columns with the subtotals, you can use the following:

=IF(SUM(J4:LN4)=0,"",
MAX(
NOT(ISFORMULA(J4:LN4))*
(J4:LN4>0)
*($J$2:$LN$2)
)
)

and hit C+S+E.

 

I believe this works. Please let me know.

@MrNobody , as variant you may expand your LOOKUP with one more filter

=IFERROR(LOOKUP(2,1/(J4:LN4<>"")/(($J$1:$LN$1="")),$J$2:$LN$2),"")
You're welcome! Good luck with your projects.
Related Conversations