Leading Zeros To Complete 3 Digit Number

jgthtrotih

Well-known Member
Joined
Aug 28, 2009
Messages
568
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hey All

i need a little help with leading zeros in excel i want a complete 3 digit number as shown blow (first chart) i used the " ' " mark to get the zeros in..i want the second chart to look the same with the zeros...

Chart 1: Examples and what I'm trying to get Achieve.
Chart 2: My actual data set.
Excel Workbook
EF
28RANDBETWEEN("000",999)
29
30
31356356
32454454
3348048
34367367
35785785
3646046
37856856
38986986
3946046
4085085
418008
Sheet


Excel Workbook
EFGHIJKLM
784019348-401-934
8
945058716450-587-16
Sheet14


Have Any Questions Let Me Know!

Using Excel 2003!

Thanks!
 
Sandeep,

Yes, order does matter..duplication is only counted when the exact same sequence of numbers is entered ie 454-536-636 and 454-536-636 ARE to be counted as duplicates.. 536-454-636 is NOT to be counted a duplicate if entered and thus gets entered into the list as a new number.

Thanks!
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I think something like this should work. Place this code in a worksheet specific module.

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Calculate()<br>    <SPAN style="color:#00007F">Dim</SPAN> ConcatVal <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> Rng <SPAN style="color:#00007F">As</SPAN> Range, X <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    ConcatVal = Range("E31").Value & "-" & Range("G31").Value & "-" & Range("I31").Value<br>    Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">If</SPAN> Range("K31").Value = "" <SPAN style="color:#00007F">Then</SPAN><br>        Range("K31").Value = ConcatVal<br>    <SPAN style="color:#00007F">Else</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> Rng = Range("K31", Range("K" & Rows.Count).End(xlUp))<br>        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>        X = WorksheetFunction.Match(ConcatVal, Rng, 0)<br>        <SPAN style="color:#00007F">If</SPAN> Err.Number > 0 <SPAN style="color:#00007F">Then</SPAN><br>            Range("K" & Rows.Count).End(xlUp).Offset(1).Value = ConcatVal<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 
Upvote 0
Sandeep,

You NEVER cease to amaze me!! once again you have conquered the challenge!!..if i may make one addition..to only calculate up to 100 rows after that i want a message to say "limit Reached"..it is not necessary..just for convenience.

Thanks!
 
Upvote 0
This should do the job

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Calculate()<br>    <SPAN style="color:#00007F">Dim</SPAN> ConcatVal <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> Rng <SPAN style="color:#00007F">As</SPAN> Range, X <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    ConcatVal = Range("E31").Value & "-" & Range("G31").Value & "-" & Range("I31").Value<br>    Application.EnableEvents = <SPAN style="color:#00007F">False</SPAN><br>    <SPAN style="color:#00007F">If</SPAN> Range("K31").Value = "" <SPAN style="color:#00007F">Then</SPAN><br>        Range("K31").Value = ConcatVal<br>    <SPAN style="color:#00007F">Else</SPAN><br>        <SPAN style="color:#00007F">If</SPAN> Range("K" & Rows.Count).End(xlUp).Row > 130 <SPAN style="color:#00007F">Then</SPAN><br>            MsgBox ("Limit Reached")<br>            <SPAN style="color:#00007F">GoTo</SPAN> 1234<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> Rng = Range("K31", Range("K" & Rows.Count).End(xlUp))<br>        <SPAN style="color:#00007F">On</SPAN> <SPAN style="color:#00007F">Error</SPAN> <SPAN style="color:#00007F">Resume</SPAN> <SPAN style="color:#00007F">Next</SPAN><br>        X = WorksheetFunction.Match(ConcatVal, Rng, 0)<br>        <SPAN style="color:#00007F">If</SPAN> Err.Number > 0 <SPAN style="color:#00007F">Then</SPAN><br>            Range("K" & Rows.Count).End(xlUp).Offset(1).Value = ConcatVal<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>1234:<br>    Application.EnableEvents = <SPAN style="color:#00007F">True</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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