Consulting

Results 1 to 5 of 5

Thread: Solved: Newbie...Stopping automatic conversion to scientific notation in VBA

  1. #1

    Solved: Newbie...Stopping automatic conversion to scientific notation in VBA



    I have product id's that in one instance, I'm just moving from one sheet to another and no conversion to scientific notation occurs. Product ID example: 5565E23. When I subsequently read that product id into a string array from a sheet and then, after some work, place it on another sheet, it gets converted to scientific notation. The destination cell is formated as text. I just want it to come out as it went in; 5565E23.

    Any help is appreciated.

  2. #2
    Hi, flip! Welcome to VBAX, where we will to our best to confuse and amuse you!

    When I started fooling around with your text string, I had no problems IF the target cell had been preformatted as Text.

    The problem is that Excel makes its own decision about how to format anything that is written into an unformatted (default) cell. It does a pretty good job of deciding what kind of value you write, but you just happened to be writing something that looks like scientific notation, soooo . . .

    I think your problems will go away if you spend a few seconds preformatting all the target cells BEFORE you write into them. It's a nuisance, but try it and see if that helps.

    Sid

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can also force it in your code

    [vba]

    With ActiveCell
    .Offset(0, 1).NumberFormat = "@"
    .Offset(0, 1).Value = ActiveCell.Text
    End With
    [/vba]
    Last edited by Bob Phillips; 02-12-2007 at 04:04 PM.

  4. #4
    Thank you. Works great.

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi flipatibm
    Welcome to VBAX
    If your question is solved, please mark it so using the thread tools dropdown
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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