1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Excel cell formats

Discussion in 'Business Applications' started by kashyap, Nov 16, 2004.

Thread Status:
Not open for further replies.
  1. kashyap

    kashyap Thread Starter

    May 31, 2004

    I've this strange requirement. I've 10 digit numbers in a column. These 10 digits can be any number from 0 to 9 and at any position. 0 can be the starting digit too.

    I customized the cells using Format option and entered 0000000000 so that all numbers are displayed even with preciding 0's. All this comes fine. But when I pick up the number from another downstream applicaiton, it takes obnly the part of the number ignoring the leading 0's.
    Can someone polease help me how to set this right!!!!!

    Thanks in anticipation.

  2. Zack Barresse

    Zack Barresse

    Jul 25, 2004

    To what is the purpose of retaining the leading zero's for dependent calculations/manipulation? If you make the leading zero's permanent, this would effectively make the numbers text. Is that what you want?

    If you want as text, here are some things you can do:

    • Preceed the cell entry with a single apostrophe (denotes textual values and will be treated as such)
    • Use a secondary cell to calculate your leading zero's (e.g. ..


    ..where A1 is your number entry)
    • Use a routine like this in your worksheet module (right click Worksheet tab --> View Code)
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
        '** Change A1:A10 to desired range of change
        If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
        '** Add desired amount of leading zero values
        Target.Value = "'" & WorksheetFunction.Rept("0", 10 - _
            Len(Target)) & Target.Value
    End Sub

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/297064

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice