Reputation: 21
I have been working on a database which needs VLOOKUP to another database. The lookup table displays values without leading zeros as:
5625698
2586585
2479653
9985632
1125478
To be specific, I want to convert these numbers to display preceding zeroes. Instead of editing each cell separately and converting it to Text Format, I want to know whether there is a shortcut to add preceding zeroes to multiple cells at once.
Regards
Upvotes: 0
Views: 1309
Reputation: 12658
There is an easy way to do it. Ok I think what you are doing here is that trying to reformat phone numbers which excel being over-smart broke in first place. Anyway you can use following steps
Upvotes: 0
Reputation: 21
I found the answer at www.extendoffice.com
The solution is to either use the CONCENTRATE function in a different column, which is similar to the suggestion of EEM (but this is not what I was looking for). Or use VBA Module with the following code:
Sub AddTextOnLeft()
'Updateby20161004
Dim Rng As Range
Dim WorkRng As Range
Dim addStr As String
On Error Resume Next
xTitleId = "Add Text"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
addStr = Application.InputBox("Add text", xTitleId, "", Type:=2)
For Each Rng In WorkRng
Rng.Value = addStr & Rng.Value
Next
End Sub
Upvotes: 0
Reputation: 6659
Use this formula to add leading zeros and convert the number to text
=TEXT(XXX,"00000000")
Upvotes: 0