+ Reply to Thread
Results 1 to 6 of 6

Cell shows leading zero but physically its not there

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    826

    Cell shows leading zero but physically its not there

    So please see my attached workbook.

    Columns E/F/H and I show leading zeros
    That is also what I need.
    However E F and H only show the leading zero but don't actually have it....
    So thats screwing up my lookups.

    How can I make sure the leading zero's become "physical" like column I?
    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    06-28-2004
    MS-Off Ver
    Home/Office 2016
    Posts
    259

    Re: Cell shows leading zero but physically its not there

    format cells as number

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Cell shows leading zero but physically its not there

    Maybe:

    Sub rpinxt()
    Dim rcell As Range
    For Each rcell In Range("E1:E" & Range("E" & Rows.Count).End(3).Row)
        rcell.Value = "'0" & rcell.Value
    Next rcell
    For Each rcell In Range("F1:F" & Range("E" & Rows.Count).End(3).Row)
        rcell.Value = "'00" & rcell.Value
    Next rcell
    For Each rcell In Range("H1:H" & Range("F" & Rows.Count).End(3).Row)
        rcell.Value = "'000" & rcell.Value
    Next rcell
    End Sub

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,345

    Re: Cell shows leading zero but physically its not there

    Based on a lot of the questions that I see here, this illustrates a couple of those spreadsheet programming concepts that we need to somehow come to understand in order to be effective spreadsheet programmers.

    On the one hand, in column E, F, and H, we have the difference between "actual cell value" and "formatted, displayed value". When the actual value is different from what we see (in your case, the leading, insignificant zeros are not actually part of the cell's value), that can create confusion.

    On the other hand, we also have the distinction between "numbers stored as numbers" (columns E, F, H) and "numbers stored as text" (column I). Text is the best data type for a "what you see is what you get" kind of display. However, this forum is full of the kinds of problems that can be encountered from "numbers stored as text". For example, the text string "2" is greater than the text string "10". Because Excel treats numbers stored as text differently than it treats numbers stored as numbers, you get a lot of unexpected behavior.

    Part of your task as a programmer is to decide which "data type" will be most useful. If column I is really your goal (to have numbers stored as text strings), then you will need to get used to working with them. Hand entered data will need to be preceeded by an apostrophe, so Excel will recognize the number as a text string. Any values that are calcluated from other values will need to be nested inside of the =TEXT() function (to convert the numbers to text) https://support.office.com/en-us/art...rs=en-US&ad=US You will also need to become familiar with the pitfalls around storing numbers as text, so that you can deal with those cases as well.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    826

    Re: Cell shows leading zero but physically its not there

    Sorry for the late response.
    Thanks JOHN H. DAVIS worked like a charm.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Cell shows leading zero but physically its not there

    You're welcome. Glad to help out and thanks for the feedback.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 04-12-2013, 01:17 PM
  2. [SOLVED] Function Arguments window shows result, cell shows a 0
    By fluffsmckenzie in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-09-2013, 05:48 PM
  3. Leading zeroes - cell shows it, value does not
    By obiwaynekenobi in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 09-05-2008, 06:32 PM
  4. [SOLVED] cell shows 20. Formula shows 20. why not 540/27
    By griswold in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 05:05 PM
  5. [SOLVED] cell shows 20. Formula shows 20. why not 540/27
    By griswold in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1