+ Reply to Thread
Results 1 to 12 of 12

Help with number formatting

  1. #1
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Help with number formatting

    Hi,

    I am using the following macro to get data from one workbook, and copy it to another:


    Please Login or Register  to view this content.
    In the last part of my code, I am trying to apply the number format of "00000000", but it doesn't seem to be working. If I click on a cell with the imported data, there are no leading zeros in the formula bar.

    Help please!

    Thank you,
    Carlos

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,630

    Re: Help with number formatting

    there are no leading zeros in the formula bar.
    There won't be. Formatting is about what you see displayed in the cell, not the value of the cell. So, 1234 will always show in the formula bar as 1234, even though it is displayed as 00001234 with a Custom Format of "00000000".
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    Hi TMS. Thank you for the quick reply.

    The thing is, the source workbook from where I am "getting" the numbers has leading zeros, both in the cells, and in the formula bar. I need the leading zeros to come over to the second workbook from the first one. Without them, my lookup formulas are not working.

    Can my above code be modified to pull the numbers with the leading zeros?

    Thank you,
    Carlos

  4. #4
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: Help with number formatting

    Change the .formula to .value or .text

    I think using .value will do the trick. but if there are still problems then use .text
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    Hi Roel,

    Thanks for the reply.

    Unfortunately, neither .value or .text worked. Actually, .text threw an error.

    So frustrating!

    I am a vba dummy, so I don't know what I am doing, but I tried changing the first .value to .copy, and the second .value to a paste special values, but that just made Excel go blank and I had to kill it via task manager

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,120

    Re: Help with number formatting

    Try
    Please Login or Register  to view this content.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,630

    Re: Help with number formatting

    Ok, if you're seeing leading zeroes in the formula bar, then the cell is formatted as text, or has a leading apostrophe to force the number into text format. Sometimes data comes from other sources, for example, a web site, and appears as text although the cell is formatted as numeric or general. Not sure why that happens, but it does, possibly the encoding.

  8. #8
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    Hi Fluff,

    When I try .Value and .Text, nothing pulls into the workbook. I don't get any error messages or anything, but nothing pulls in

  9. #9
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    I just found out something by chance. In my source file exist all of the numbers with leading zeros. The formatting is "General".

    Here is what I found out: If I click in a cell with one of the numbers with leading zeros, and edit it in any way, and then hit enter, the leading zeros disappear.

    For example, if the number is 00010268, and I click in the cell, and only change the 2 to a 3, when I click out of it, or hit enter, the leading zeros disappear.

    Why is this happening?

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,630

    Re: Help with number formatting

    You've just converted the format to numeric or general.

  11. #11
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    There has to be some way to do this. If I do a look up from my workbook to my source workbook, I get matches.

    When I pull in the data from my source workbook into my workbook via the above macro, and then try to do lookups, they don't work.

    The formatting is such that the lookups work when the data is in two different workbooks, but when I run the macro and pull in the data from source workbook to workbook, the formatting (or something) changes such that the lookups no longer work. Even though I am doing the same lookups!

  12. #12
    Forum Contributor
    Join Date
    10-03-2015
    Location
    North Carolina, USA
    MS-Off Ver
    Office 365
    Posts
    167

    Re: Help with number formatting

    I could not find a solution to the above problem, but I found a workaround that suits my needs fine.

    Thanks to everyone who spent time trying to help me!

+ 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. number-comma-number formatting problem. Thousands, and string
    By JimmyWilliams in forum Excel General
    Replies: 1
    Last Post: 11-28-2017, 06:35 PM
  2. [SOLVED] Apply formatting if a number repeats in one of the three cells following this number
    By ×_× in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-02-2015, 10:57 AM
  3. [SOLVED] Add leading zeroes to number, number formatting
    By YOO629 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-29-2015, 04:26 AM
  4. Number Formatting and Conditional Formatting
    By morayman in forum Excel General
    Replies: 1
    Last Post: 01-23-2014, 04:03 AM
  5. [SOLVED] Formatting to make 2 digit number show up at 3 digit number.
    By cadamhill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2012, 06:58 PM
  6. Conditional Formatting quirk with Number formatting
    By ChemistB in forum Excel General
    Replies: 9
    Last Post: 07-20-2011, 08:44 AM
  7. Replies: 3
    Last Post: 02-12-2009, 01:08 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