Leading Zero iwith Concat

allieanne

New Member
Joined
Jan 19, 2009
Messages
6
I've got two columns, department and position. I want to smush them together into one in order to use vlookup from another sheet.

The position number needs to be 3 digits long in the final product. I have 1,2, and 3 digit position numbers. I can of course make it show the leading zeros using formatting, but when I concat it drops the zeros. I need the result to be 111-001 not 111-1. There's all sorts of manipulations I could do to make this work, but wondering if there is a simple way that I'm overlooking?
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,494
Office Version
365
Platform
Windows
Use the TEXT function, i.e.
Code:
=TEXT(A1,"000") & "-" & TEXT(B1,"000")
 
Last edited:

hotabae

Board Regular
Joined
Apr 18, 2018
Messages
167
I would normally recommend formatting the position column.

Highlight the column, right click, "Format Cells..." , "Number Tab", Category = "Custom" , Type "000" (without quotes).


Dunno if there is an easier solution than that.

Edit: Doesn't meet requirements for Vlookup - See #4
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,494
Office Version
365
Platform
Windows
I would normally recommend formatting the position column.

Highlight the column, right click, "Format Cells..." , "Number Tab", Category = "Custom" , Type "000".
Formatting the column does not change the underlying value, just the way it is presented to the user.
In order for the VLOOKUP to work, you MUST update the underlying result, like I showed in the previous response.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
51,494
Office Version
365
Platform
Windows
If you prefer to use CONCATENATE, you would do it like this:
Code:
=CONCATENATE(TEXT(A1,"000"),"-",TEXT(B1,"000"))
I prefer the first method I posted, as it is less typing!;)
 

Forum statistics

Threads
1,082,383
Messages
5,365,142
Members
400,825
Latest member
Sreekanth_21

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top