PC Review


Reply
Thread Tools Rate Thread

Add leading zeros fill space

 
 
Rob
Guest
Posts: n/a
 
      11th Nov 2007
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 With Quote
 
 
 
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      11th Nov 2007
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
>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      11th Nov 2007
=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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
Rob
Guest
Posts: n/a
 
      11th Nov 2007
Thanks Bob and Joel, the REPT worked a treat.

Regards, Rob

"Bob Phillips" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> =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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace leading zeros with leading spaces ? Gary Microsoft Excel Programming 4 7th Jan 2010 11:39 AM
Adding in leading zeros and a space to a text field in a table Bill Microsoft Access 4 15th Jul 2008 07:00 PM
How do I make a number have leading zeros to fill width of cell? =?Utf-8?B?TWF4X1JlYm8x?= Microsoft Excel Misc 4 14th Oct 2005 05:31 PM
save text field w/ leading zeros in .csv format & not lose zeros? =?Utf-8?B?UXVlcw==?= Microsoft Excel Misc 1 4th May 2005 06:21 PM
Need to fill-in leading zeros Bonnie Microsoft Access Queries 5 17th Aug 2004 10:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:53 PM.