Formula to return a number based on the content of another cell

canarycat123

New Member
Joined
Sep 1, 2021
Messages
27
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi there, I’m hoping someone can help me with this question.

I have a series of formula being used to generate unique reference numbers, finishing with CONCATENATE, as seen in the screencap attached. I am using a simple =IF(H60=””,””,ROW()-2) formula to generate the final four digits of the reference number. However, what I am trying to achieve is slightly more complex.

The first portion of characters, in this example KGV and MISC (produced in another cell using VLOOKUP), represent different geographical areas. What I would like to achieve is a formula that can identify the next number in the series related to each geographical area. So, in the attached example I would like MISC to return MISC-LS-020-001 (rather than -0058), as that would be the first KGV record in the worksheet. If I were then to add another MISC I want it to return 002 and so on. If I were then to add another KGV record it should start with the next number in the sequence related to KGV, 0058 in this example.

Any help/advice would be appreciated!
 

Attachments

  • Ref Example.PNG
    Ref Example.PNG
    3.3 KB · Views: 24

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Hi there, unfortunately my employers doesn't allow 3rd party add-ons.
 
Upvote 0
In that case can you just copy/paste some sample data to the board.
 
Upvote 0
Does this help?

Formula's for each column are as follows:

Column A: =VLOOKUP(Hxx,Building,2,FALSE)
Column B: =VLOOKUP(Hxx,Location,2,FALSE)
Column C: =VLOOKUP(Hxx,Level,2,FALSE)
Column D: =ROW()-2
Column E: =CONCATENATE(Axx,"-",Bxx,"-",Cxx,"-","00",Dxx)


KGVLS010
52​
KGV-LS-010-0052
KGVLS010
53​
KGV-LS-010-0053
KGVLS010
54​
KGV-LS-010-0054
KGVLS010
55​
KGV-LS-010-0055
KGVLS010
56​
KGV-LS-010-0056
KGVLS010
57​
KGV-LS-010-0057
MISCLS020
58​
MISC-LS-020-0058
 
Upvote 0
Thanks for that, how about
+Fluff 1.xlsm
ABCDE
1
2KGVLS1052KGV-LS-10-0001
3KGVLS1053KGV-LS-10-0002
4KGVLS1054KGV-LS-10-0003
5KGVLS1055KGV-LS-10-0004
6KGVLS1056KGV-LS-10-0005
7KGVLS1057KGV-LS-10-0006
8MISCLS2058MISC-LS-20-0001
Test
Cell Formulas
RangeFormula
E2:E8E2=TEXTJOIN("-",,A2:C2,TEXT(COUNTIFS(E$1:E1,A2&"-"&B2&"-"&C2&"-*")+1,"0000"))

Brilliant! I'd day we're 80% there. In the attached example, because there are now 2 KGV records the final portion of the ref should be 002. Is that possible?
 

Attachments

  • Capture.PNG
    Capture.PNG
    5.9 KB · Views: 14
Upvote 0
It should give you that, as can be seen in post#6
 
Upvote 0
It should give you that, as can be seen in post#6

Ah yes, I made a tweak and now it works. The last thing to overcome is a follows, hopefully there's a way of doing this: The last four digits of the ref should be based only on the location (first element of the ref). In the attached example, the four digit ref is starting from 0001 when the second and third elements form a unique combination. In the attached example, even though the second and third elements are different, because the first portion is 'JC' it should number from 0001-0004 consecutively. Does that make sense?
 

Attachments

  • Capture.PNG
    Capture.PNG
    3.8 KB · Views: 13
Upvote 0
Do you mean that the last 4 numbers should increment solely based on the value in col A?
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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