+ Reply to Thread
Results 1 to 4 of 4

Removing leading zeros in code

  1. #1
    Registered User
    Join Date
    09-24-2007
    Posts
    9

    Removing leading zeros in code

    Hope someone can help, I get a report from payroll, all the numbers are 8 digits so if pay ID is 00045551 this is what it displays, I'm trying to reconcile it against something that will not display the leading zeros no matter how we try to format the cells therefore in this spreadsheet it shows the same number as 45551, when I check the numbers against each other in code it errors on these lines as it does not recognise that they are the same number. How can I either remove the leading zeros in one sheet or add them up to the 8 digits in the other.....

    Apologies if I've rambled.

    Sam

  2. #2
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    199
    If you want to keep the zeros in the cell you can click on the cell or range of cells that it would apply to and change the format to show as follows:

    "00000000"

    Just enter that in the "Type" field and you should get the desired result.

    Hope that helps.

  3. #3
    Registered User
    Join Date
    09-24-2007
    Posts
    9
    Thank you, it kind of helps, I've done what you suggested and the leading zeros do now show in Excel however the VBA code still doesn't think they match, I'll attach an extract of the code that I've used to compare the two...
    Sam

    I've just realised I probably posted this in the wrong forum - sorry, have added the code.
    Attached Files Attached Files
    Last edited by zakcat1972; 02-27-2008 at 01:00 PM.

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    The problem is that your second set (which was originally showing up without the leading zeros) is being seen as numbers and the other set that it is being compared to is being seen as Text. You need to convert everything either to all text or all numbers.

    ChemistB

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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