+ Reply to Thread
Results 1 to 9 of 9

Problem with number format

  1. #1
    Registered User
    Join Date
    02-15-2019
    Location
    Athens, Greece
    MS-Off Ver
    2013
    Posts
    32

    Problem with number format

    Hello.

    I have a problem.

    I have set this line of code:

    destws.Range("N" & i).Value = sourcews.Range("C" & i).Value
    destws.Range("N" & i).NumberFormat = "0"

    So far so good. The format numbers are indeed just as i want them, like this: 9999990002637420


    Then, i put in another part of my code these:

    For i = 2 To LastRow
    c4a = destws.Range("N" & i).Value & "&" & destws.Range("J" & i).Value
    destws.Range("A" & i).Value = c4a
    destws.Range("A" & i).NumberFormat = "0"

    Next

    At that column i get this result: 9,99999000263742E+15&CRS4958054

    Can someone plesae tel me what i'm doing wrong?

    Thanks in advance

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

    Re: Problem with number format

    it goes wrong because your outcome is not a number in the second piece of code, because of the joining of 2 cellvalues. so the first value of N column is put in as unformatted into the c4a-string and turns to scientific notation because of its length

    Try:
    Please Login or Register  to view this content.

    please note that all code should be put in code tags(use #-icon on the editorbar)

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,883

    Re: Problem with number format

    FYI - Please use Code tag for codes. (# button).

    There's few issues here.
    1. If you want formatted text from cell as is. You should use Cells/Range.Text instead of value. Or use Format() function.
    2. Since c4a is a string, applying NumberFormat to destination cell does nothing.

    So try something like...
    Please Login or Register  to view this content.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  4. #4
    Registered User
    Join Date
    02-15-2019
    Location
    Athens, Greece
    MS-Off Ver
    2013
    Posts
    32

    Re: Problem with number format

    CK76 That's it! Thank you very much!
    Last edited by manosalexo; 02-15-2019 at 09:53 AM.

  5. #5
    Registered User
    Join Date
    02-15-2019
    Location
    Athens, Greece
    MS-Off Ver
    2013
    Posts
    32

    Re: Problem with number format

    Roel Jongman This unfortunately popped a run-time error but thank you for answering!
    Last edited by manosalexo; 02-15-2019 at 09:53 AM.

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

    Re: Problem with number format

    must be a typo somewhere.. works in my testsheet

    but there is always more then one way to get to the same result.

  7. #7
    Registered User
    Join Date
    02-15-2019
    Location
    Athens, Greece
    MS-Off Ver
    2013
    Posts
    32

    Re: Problem with number format

    Another problem i'm facing is this. Even in numeric or even in text format it seems that my last digit is not the same. For example. This number 9999990002637429 turns out to become 9999990002637420. I guess EXCEL autorounds my numbers. Is there anyway to avoid this?
    Last edited by manosalexo; 02-15-2019 at 10:24 AM.

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Problem with number format

    Excel will only ever display a max of 15 significant digits for numbers. If you want more than that, you need to keep the results as text.
    Entia non sunt multiplicanda sine necessitate

  9. #9
    Registered User
    Join Date
    02-15-2019
    Location
    Athens, Greece
    MS-Off Ver
    2013
    Posts
    32

    Re: Problem with number format

    Quote Originally Posted by shg View Post
    Excel will only ever display a max of 15 significant digits for numbers. If you want more than that, you need to keep the results as text.
    Thamks a lot!

+ 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. Custom number format problem!!!!
    By Jhon Mustofa in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 01-22-2014, 04:40 PM
  2. Number format problem
    By tigorin in forum Excel General
    Replies: 19
    Last Post: 02-11-2013, 05:32 PM
  3. Number Format problem
    By onoank in forum Excel General
    Replies: 3
    Last Post: 04-18-2012, 01:18 PM
  4. NUMBER FORMAT Problem
    By esj001 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-31-2011, 02:14 PM
  5. number format problem
    By kikieb in forum Excel General
    Replies: 1
    Last Post: 07-24-2009, 10:38 AM
  6. Number Format Problem
    By Inexpert in forum Excel General
    Replies: 1
    Last Post: 08-10-2008, 07:58 AM
  7. Number format problem
    By Ali_238 in forum Excel General
    Replies: 3
    Last Post: 11-28-2006, 07:13 AM
  8. Number Format Problem
    By kola5567 in forum Excel General
    Replies: 1
    Last Post: 06-24-2005, 03: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