r/excel • u/mcwhitney • Sep 10 '20
solved Incremental numbering skipping blank cells as part of an IF/AND statement?
I'd like excel to automatically assign a unique number to each new approved grant, while leaving denied grants without a number. The number should indicate the fiscal year plus a sequential number. I've got the formula figured out to get the FY indicated, but I cannot figure out how to make the numbers incrementally increase. The formula I'm using right now is =IF((AND(N6>DATEVALUE("6/30/2019"),N6<DATEVALUE("7/1/2020"))),"FY20-1",IF((AND(N6>DATEVALUE("6/30/2020"),N6<DATEVALUE("7/1/2021"))),"FY21-1",IF((AND(N6>DATEVALUE("6/30/2021"),N6<DATEVALUE("7/1/2022"))),"FY22-1","")))
Here's what the data looks like:
Ideally the FY20 grants would be numbered FY20-1, FY20-2, FY20-3, etc and the same for the FY21 grants. Is this even possible?
First time ever posting on reddit so apologies if I've made some errors here!
Thanks all!
1
u/basejester 336 Sep 10 '20
If you put the FY20, FY21, etc. in column A and Approved in column B where appropriate, then you can find the sequence number by counting the number of matching FY numbers with Approved at this row and above and concatenate it with the A column.
1
u/i-nth 789 Sep 10 '20
I'd be concerned about allocating a grant number using a formula. If the status of a grant is changed, then the formula for subsequent applications would recalculate and the grant numbers would change.
1
u/[deleted] Sep 11 '20
If your fiscal month is 7, this will give you the fiscal period end-date:
Using that, putting in our "FY" prefix at the front and using the TEXT function, we can get your 2-digit fiscal-year display like this:
Using that, we can construct an IF statement (to make sure K is "A" and N has a value greater-than 0 -- assumption for that is "we have a date there").
If those 2 checks pass muster, we can check all the FY entries above our current position, find all the ones associated w/the appropriate fiscal year, look at the sequential numbers previously auto-assigned, grab the highest (MAX) one and add a 1 to it.
Like this:
Since we're passing a range (top to current row in B) to IF, that becomes an array formula. So if you're not on the new array engine, you'll need to submit that with CSE (Ctrl Shift Enter) instead of the regular Enter you're used to submitting formulas with.
So, put that in B2, submit with CSE and copy down as needed.
Sample of results (gray cells in B): https://imgur.com/OoiIXS9
Large Caveat: See warning from u/i-nth. Auto-assigning sequential numbers like this is fraught with all kinds of dangers and potential pitfalls.
•
u/AutoModerator Sep 10 '20
/u/mcwhitney - please read this comment in its entirety.
Once your problem is solved, please reply to the answer(s) saying
Solution Verifiedto close the thread.Please ensure you have read the rules -- particularly 1 and 2 -- in order to ensure your post is not removed.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Decronym Sep 10 '20 edited Sep 11 '20
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Beep-boop, I am a helper bot. Please do not verify me as a solution.
16 acronyms in this thread; the most compressed thread commented on today has 24 acronyms.
[Thread #453 for this sub, first seen 10th Sep 2020, 23:36] [FAQ] [Full list] ^[Contact] [Source code]