Adding a prefix based on the value of another cell

sdocherty23

New Member
Joined
Dec 28, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello All,

I need a bit of assistance with adding a prefix to an existing value in a cell based on the value that is in another cell.
Here is the scenario. I have a field called Job Type. This field has a dropdown list in it that is coming off of a named range in a second sheet in the same workbook.
When I select a value from the Job Type dropdown, such as Residential, it populates the field, but I want to add a prefix of the letter "R" in front of a defined job number in a field called Job #.
An example of this is seen below
JobNumber1.jpg


The Job # field has a formula in it that I used to generate the job number as seen below:
JobNumber2.jpg


I am not even sure if it is possible to as an example add the "R" for Residential in front of the -1-23 as a prefix.
Would be very interested in seeing if this is possible.

Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Excel Formula:
=IF(F13<>"",XLOOKUP(F13,$C$4:$C$10,$B$4:$B$10,"",0,1)&"-"&ROW()-12&"-23","")
 
Upvote 0
Solution
=IF(F13<>"",XLOOKUP(F13,$C$4:$C$10,$B$4:$B$10,"",0,1)&"-"&ROW()-12&"-23","")
Thank you very much for this!! It works like a charm.
I have one more question for you about this formula.
In the first image above, I have the left hand job # column (column A) where I want the job numbers to go from 1 - 320
In the second Job # column on the right hand side (column K) I want the job # to go from 321 - 640.
How do I continue the job # in column K
jobnumber3.jpg
 

Attachments

  • jobnumber3.jpg
    jobnumber3.jpg
    123.5 KB · Views: 5
Upvote 0
And presumably the "Job Type" selection for column K would be in column P? If so, then this formula should work in column K:

Excel Formula:
=IF(P13<>"",XLOOKUP(P13,$C$4:$C$10,$B$4:$B$10,"",0,1)&"-"&ROW()+308&"-23","")
 
Upvote 0
Hello kevin9999,

Thank you sooooooo much for your help and very quick reply's!!!
Both of your formula's worked amazing!!
 
Upvote 0
You're welcome, and thanks for the feedback :)
Hello kevin9999,

In regards to the formula that you provided to me, as seen below:
=IF(F13<>"",XLOOKUP(F13,$C$4:$C$10,$B$4:$B$10,"",0,1)&"-"&ROW()-12&"-23","")

The -23 for me is the year. I have a field on the spreadsheet that holds the year as seen below:
jobnumber3.jpg


Is it possible to have the formula grab the year from the field above highlighted in red and parse out the first two values and add the 23 into the formula so that the year only has to be entered in the Cell beside the word Year and I would not have to change the formula each year?

Let me know if you have any thoughts on this please.

Thank you
 
Upvote 0
Try this (untested)

=IF(F13<>"",XLOOKUP(F13,$C$4:$C$10,$B$4:$B$10,"",0,1)&"-"&ROW()-12&"-"&Right($B$3,2),"")
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,893
Members
449,194
Latest member
JayEggleton

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