Numerical Code Generation Based off of Text from other Columns

iceshark17

New Member
Joined
Jun 24, 2014
Messages
7
I have a specific code structure that I would like to be automatically generated based off of text from other columns in the same row.

The code Structure is: XX.XXXX.XXXX (PROCESS AREA . COMPONENT/DISCIPLINE . ITEM)

The first two digits are meant to represent an "Area" (##.XXXX.XXXX)

The next four digits are meant to represent a "Component" (XX.##XX.XXXX) as well as a "Discipline" if applicable (XX.XX##.XXX), if not applicable the ##s will just be zeros.

The last four digits will represent an item number, 0001-9999 that will simply follow the order in which the row was entered.

Example of text:

R9PpmYh.jpg


4StGCQB.jpg


BTIB7Nf.jpg


so, for example, I'd like to fill out a row such as the one below with all the text information and have the code automatically generate.

Zli1IDt.jpg


Any guidance would be much appreciated. Thank you!
 
Hi Peter,

1. I took the (red & black headed) tables and moved them to be columns within a larger, single table. This is what I meant by saying I tried to combine your method with Mark's.

(FYI I pasted the same image twice, one w color and one black and white in case one was easier to read/follow than the other.)

2. The 'Process Area' Table, for example, moved to columns F & G. The 'Component' table moved to columns H & I. The 'Discipline' Table moved to columns J & K.

3. Thanks, I wasn't sure how so I had just pasted the formula at the end of my last post. I tried downloading the MR. Excel HTML maker and it won't open. I'm on a work machine as well and probably shouldn't tweak any settings, hopefully we can make do with the pasted formula for now.

Thank you
 
Last edited:
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi Peter,

1. I took the (red & black headed) tables and moved them to be columns within a larger, single table. This is what I meant by saying I tried to combine your method with Mark's.

(FYI I pasted the same image twice, one w color and one black and white in case one was easier to read/follow than the other.)

2. The 'Process Area' Table, for example, moved to columns F & G. The 'Component' table moved to columns H & I. The 'Discipline' Table moved to columns J & K.

3. Thanks, I wasn't sure how so I had just pasted the formula at the end of my last post. I tried downloading the MR. Excel HTML maker and it won't open. I'm on a work machine as well and probably shouldn't tweak any settings, hopefully we can make do with the pasted formula for now.

Thank you

Hi Iceshark17!

I think that the best approach is with 3 separate tables (not with one table) and with the table labels/headers (not cells address) in the formula. So you can create new codes without problem and you can put the 3 tables in another sheet without problem too.

Here is the formula with 3 tables of codes (the names of the tables are TArea, TComp and TDisc), one table main (the name of the tabel is Main) and with labels (headers) in the formula:

In A2 in the table Main:

=IFERROR(TEXT(INDEX(TArea[Code2],MATCH([@Area],TArea[Process Area],0)),"00"),"00")&"."&
IFERROR(TEXT(INDEX(TComp[Code3],MATCH([@Component],TComp[Component],0)),"00"),"00")&
IFERROR(TEXT(INDEX(TDisc[Code4],MATCH([@[Discipline (if applicable)]],TDisc[Discipline],0)),"00"),"00")&"."&TEXT([@Item],"0000")


ABCDEFGHIJKLMNO
1CodeAreaComponentDiscipline (if applicable)ItemCode2Process AreaCode3ComponentCode4DisciplineDescription
2 50.0350.0001 TW ReservoirField OrderStructural10Offsite1Contract10CivilStaff Gauge
331.0560.0002LOXDesign ClarificationMechanical21Site/General2Change Order20Corrosion ProtectionColumn Numbering
4 50.0150.0003 TW ReservoirContractStructural310Flow Control Vault3Field Order30Landscaping5 ton weight limit signage
531.0300.0004LOXField Order420Pre-Treatment4Value Enginnering40ArchitecturalP&IDs
630Ozone5Design Clarification50Structural
731LOX6Submittal60MechanicalVerify
840Filters7Request for Information
950TW Reservoir
*********************************************************************************************************************************************************************************

<tbody>
</tbody>


Markmzz
 
Last edited:
Upvote 0
In relation to the HTML maker, you shouldn't be trying to 'Open' it. Some installation instructions are given in post #2 of the thread linked to from the 'Look here' link in my signature block below.


I think that the best approach is with 3 separate tables (not with one table) and with the table labels/headers (not cells address) in the formula.
I agree with Mark & my suggestion is similar, though I interpreted post #1 as saying it was only the "Discipline" column of the result table that could be empty. Perhaps I was wrong about that?

I also agree with Mark that the input tables could go on another sheet if you want but I have included all 4 tables (same names as Mark used) on the one sheet. So below,
Table 'Main' is in columns A:E
Table 'TArea' in cols F:G
Table 'TComp' in cols H:I
Table TDisc' in cols J:K

In practice, you might choose to separate each table by a blank column for better visual clarity.

In your answers to my questions, you didn't address the issue of the 'Code' columns now displaying simple numbers like 30 instead of text like 50.0150.0001 but I will also go with the simple numbers for now. However, to help simplify the formula a bit, I'm suggesting formatting the 'Code' column of each table as Text and then entering the 2-digit code directly. In the TArea table and TDisc table include a "." at the end of each 2-digit number as shown.

For table Main, formulas for Code and Item are shown.

Excel Workbook
ABCDEFGHIJK
1CodeAreaComponentDisciplineItemCodeProcess AreaCodeComponentCodeDiscipline
250.0150.0001TW ReservoirContractStructural:)-1,&quot;0000&quot;)]000100.Offsite01Contract10.Civil
320.0660.0002Pre-TreatmentSubmittalMechanical000201.Site/General02Change Order20.Corrosion Protection
431.0300.0003LOXField Order000310.Flow Control Vault03Field Order30.Landscaping
520.Pre-Treatment04Value Engineering40.Architectural
630.Ozone05Design Clarification50.Structural
731.LOX06Submittal60.Mechanical
840.Filters07Request for Information
950.TW Reservoir
10
Code (3)
 
Last edited:
Upvote 0
Peter & Mark, thank you very much for your help.

Mark, I separated out the tables on different sheets, applied your formula and got it to work.

Peter, I apologize for being a bit vague in my posts. I did want simple numbers in my reference tables but I had tried to show it in the context of the resulting "Code" which will ultimately be the item's filing number. I tried to use your formula thinking it should work the same as Mark's regardless of where the referenced tables exist within the workbook as I have now referenced them by their table names and not their cells (I had to look up how to name tables so sorry for being slow to catch up). If you could perhaps clarify, am I supposed to be replacing any part of your code after pasting the formula? I tried to replace the '
Code:
' portion with '[Code2]' , '[Code3]' , etc..after it had not worked on the first go but I can't tell what else may need to be updated. If it's not apparent, please don't worry as I have something functional at the moment.

Thank you both again you are life savers on this forum.
****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE]
<tbody>[TR]
[TD]=INDEX(TArea[Code],MATCH([@Area],TArea[Process Area],0))&INDEX(TComp[Code],MATCH([@Component],TComp[Component],0))&IF(D2="","00.",INDEX(TDisc[Code],MATCH[COLOR=#0000FF]([@Discipline],TDisc[Discipline],0)[/COLOR]))&[@Item][/TD]
[/TR]
</tbody>[/TABLE]
</body>
 
Upvote 0
If you could perhaps clarify, am I supposed to be replacing any part of your code after pasting the formula? I tried to replace the '
Code:
' portion with '[Code2]' , '[Code3]' , etc..after it had not worked on the first go but I can't tell what else may need to be updated. If it's not apparent, please don't worry as I have something functional at the moment.[/QUOTE]If you have Mark's working I would just stick with that as mine wasn't a lot different anyway. :)
 
Upvote 0
Peter & Mark, thank you very much for your help.

Mark, I separated out the tables on different sheets, applied your formula and got it to work.

Hi Iceshark17,

You're welcome and thanks for the feedback.

Markmzz
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,979
Members
448,934
Latest member
audette89

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