Results 1 to 11 of 11

Thread: Number Stored as text[RESOLVED]

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Resolved Number Stored as text[RESOLVED]

    Hi as the title says, i have a number stored as text in a cell.
    I know there must be a way to convert this to a number format, but when i format the cell to Number it does not convert.
    There is the error message button, but when recording a macro it does not record this action.

    I'd look in to this further, but it's the final piece of the code i need and it's pretty urgent.
    Basic probably i know, but i;ve never come across it before.
    I tried copying the value and storing it as a variable in vba
    couldnt get Cint to work.

    any help would be appreciated,
    Thanks
    Last edited by Mitch_s_s; May 3rd, 2007 at 10:08 AM.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Number Stored as text

    set the numberformat of the cell or range
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Number Stored as text

    do you mean
    range("Myrange").NumberFormat = "0.00"

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Number Stored as text

    that is the idea
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Number Stored as text

    my original post covers that

    it doesnt seem to work
    the number is still stored as text

  6. #6
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Number Stored as text

    i think Cint() method will help u..chk out the VBA help...
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  7. #7
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Number Stored as text

    ooopsss...sorry ..its INT() not cint()
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Number Stored as text

    He tried that
    Quote Originally Posted by Mitch_s_s
    I tried copying the value and storing it as a variable in vba couldnt get Cint to work.
    Lets go back to basics.

    How are you putting the number in the cell to begin with?

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Number Stored as text

    Hi Mitch

    Do me a small favor. Just check in the Formula bar on how the numbers are stored in the cell. It is possible that there is a ' (single quote) before the number for example '98732.

    In this case the numbers will always be stored as text.

    Two ways to get rid of it.

    1) either manually delete the single quote or
    2) write a code to loop thru the cells and delete the quote.

    Hope this helps...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Location
    England
    Posts
    234

    Re: Number Stored as text

    thanks for the quick response

    I've looped through the cells using int()
    i tried Cint originally an that didnt work

    int does the job!!!

    it's a csv export from a SQL query.

    thanks for your quick response

  11. #11
    Hyperactive Member nagasrikanth's Avatar
    Join Date
    Nov 2004
    Location
    India,Hyderabad.
    Posts
    420

    Re: Number Stored as text[RESOLVED]

    yep.....Im right.....
    The Difference between a Successful person and others is not a Lack of Knowledge,
    But rather a Lack of WILL

Posting Permissions

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



Click Here to Expand Forum to Full Width