+ Reply to Thread
Results 1 to 8 of 8

Convert Text to a Number - VB Code Needed

  1. #1
    Forum Contributor
    Join Date
    05-20-2008
    Location
    Virginia
    MS-Off Ver
    2003
    Posts
    129

    Convert Text to a Number - VB Code Needed

    Hello,

    I some information on an excel spreadsheet that has numbers formated as text. I can not convert them to numbers unless I hit the explanation point beside the text number. I want to do this with visual basic code, but the macro will not pick up me clicking the explanation point beside the numbers. Does anyone know the code to do this????

  2. #2
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    If the number formatted as text is in A1, you could use:

    Please Login or Register  to view this content.
    to convert the text to a number.

    HTH

    Jason

  3. #3
    Forum Contributor
    Join Date
    05-20-2008
    Location
    Virginia
    MS-Off Ver
    2003
    Posts
    129

    How To Do A Range of Cells

    Can you do a range of cells with this formula?? How would you do that

    I figured out the code for this but it looks much larger. I recorded a macro under selecting Data then doing Text To Columns, and it did what I needed it to. The code is long though.

  4. #4
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Try this for column A:

    Please Login or Register  to view this content.
    HTH

    Jason

  5. #5
    Forum Contributor
    Join Date
    05-20-2008
    Location
    Virginia
    MS-Off Ver
    2003
    Posts
    129

    Your a Genius!

    This is great and it is a heck of a lot shorter than my recorded code. My recorded code worked but it was looooonnnnggg!!!

    This is what I had:

    Please Login or Register  to view this content.
    Thank You So Much Your Help Buddy -- SEOT
    Last edited by VBA Noob; 05-28-2008 at 01:39 PM.

  6. #6
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    Glad it helped.

    As with most VBA code when you use the recorder, there is a lot of unnecessary junk in there.

    Jason

  7. #7
    Forum Contributor
    Join Date
    05-20-2008
    Location
    Virginia
    MS-Off Ver
    2003
    Posts
    129

    Thanks Again Jason !!!

    Yes, it had a lot of junk in it. I was able to cut down yours a little too. I took the array part out and it seemed to work. Thank You Jason!!!

  8. #8
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    As long as you're converting the text to General format, then you are correct, the FieldInfo can be left out. But if you were trying to convert to text, date, etc., you need that in there to let Excel know which format you need.

    Jason

+ 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