Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Add leading zeros fill space

Hi,

Using Excel 2000

I have spreadsheet that uses text entries to do a Vlookup, the look up range
has text in the format of 6 characters albeit they look like numbers with
leading zeros eg. '000100. The entry that I enter if '000100 returns the
correct result. However, when others enter they tend to just enter '100
which doesn't match. I therefore thought that if I could check the length
of their entry, I could fill with leading zeros to make it 6 characters
long.

Having tried to do this with validation, I'm now thinking this is a change
cell piece of code.

Any pointers of sample code would be appreciated.

Thank you, Rob


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Add leading zeros fill space

using a worksheet function

=REPT(0,6-LEN(A1))&A1

using VBA

Sub test()

num = 100
longstr = String(6 - Len(A1) & A1, "0")
End Sub
"Rob" wrote:

Hi,

Using Excel 2000

I have spreadsheet that uses text entries to do a Vlookup, the look up range
has text in the format of 6 characters albeit they look like numbers with
leading zeros eg. '000100. The entry that I enter if '000100 returns the
correct result. However, when others enter they tend to just enter '100
which doesn't match. I therefore thought that if I could check the length
of their entry, I could fill with leading zeros to make it 6 characters
long.

Having tried to do this with validation, I'm now thinking this is a change
cell piece of code.

Any pointers of sample code would be appreciated.

Thank you, Rob



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Add leading zeros fill space

=VLOOKUP(REPT("0",6-LEN(A1))&A1,L1:P9,2,FALSE)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Rob" wrote in message
...
Hi,

Using Excel 2000

I have spreadsheet that uses text entries to do a Vlookup, the look up
range has text in the format of 6 characters albeit they look like numbers
with leading zeros eg. '000100. The entry that I enter if '000100 returns
the correct result. However, when others enter they tend to just enter
'100 which doesn't match. I therefore thought that if I could check the
length of their entry, I could fill with leading zeros to make it 6
characters long.

Having tried to do this with validation, I'm now thinking this is a change
cell piece of code.

Any pointers of sample code would be appreciated.

Thank you, Rob



  #4   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Add leading zeros fill space

Thanks Bob and Joel, the REPT worked a treat.

Regards, Rob

"Bob Phillips" wrote in message
...
=VLOOKUP(REPT("0",6-LEN(A1))&A1,L1:P9,2,FALSE)

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)



"Rob" wrote in message
...
Hi,

Using Excel 2000

I have spreadsheet that uses text entries to do a Vlookup, the look up
range has text in the format of 6 characters albeit they look like
numbers with leading zeros eg. '000100. The entry that I enter if
'000100 returns the correct result. However, when others enter they tend
to just enter '100 which doesn't match. I therefore thought that if I
could check the length of their entry, I could fill with leading zeros to
make it 6 characters long.

Having tried to do this with validation, I'm now thinking this is a
change cell piece of code.

Any pointers of sample code would be appreciated.

Thank you, Rob





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Leading Zeros Ben Watts Excel Worksheet Functions 8 September 26th 07 05:44 PM
leading zeros P. Zicari Excel Discussion (Misc queries) 3 November 18th 05 04:31 PM
How do I make a number have leading zeros to fill width of cell? Max_Rebo1 Excel Discussion (Misc queries) 4 October 14th 05 05:31 PM
Leading zeros LeePotts Excel Discussion (Misc queries) 2 August 17th 05 02:46 PM
save text field w/ leading zeros in .csv format & not lose zeros? Ques Excel Discussion (Misc queries) 1 May 4th 05 06:21 PM


All times are GMT +1. The time now is 10:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"