+ Reply to Thread
Results 1 to 3 of 3

Change imported numbers in text format to numbers

Hybrid View

  1. #1
    Registered User
    Join Date
    07-24-2014
    Location
    Phoenix
    MS-Off Ver
    2007
    Posts
    21

    Change imported numbers in text format to numbers

    Greetings

    I have a macro that imports some numbers from a file where they are formatted as text, in the new sheet they appear with the little green icon on the top left telling me that the numbers have been stored as text. Attached is a workbook showing my problem, at the top are the ones stored as text, at the bottom are ones added by the macro formatted as numbers. I need them in the same format to use in a pivot table.


    Already tried simply formatting and also tried copying and pasting values

    Thanks for the help
    Attached Files Attached Files

  2. #2
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,725

    Re: Change imported numbers in text format to numbers

    Look at cells B2:B12. The formula I used to convert the text dates to date values is =--A2. I just copied down. The "--" in front of the A2 might be confusing. It is one of many ways to coerce the underlying numeric value in the text representation of numbers. Simply adding =0+A1 works as well as =1*A1.

    Hope this helps.

    Edit: I almost forgot. You can copy and paste special/values the B2:B12 cells. Then just move the entire range over to column A replacing the text.
    Last edited by FlameRetired; 10-02-2014 at 12:20 PM.

  3. #3
    Registered User
    Join Date
    07-24-2014
    Location
    Phoenix
    MS-Off Ver
    2007
    Posts
    21

    Re: Change imported numbers in text format to numbers

    Thanks for the info, that allowed me to create the macro code I needed. In case anyone else has the question and needs the macro code:
    The variable "lastrow" stores the final row in the worksheet
    CS is the first empty column where I could use the information above
            
            ...
            'This section is done to convert the numbers written as text in column A to numbers
            Range("CS2").Formula = "=RC[-96]*1"
            Range("CS2").Select
    
            'This serves as pulling the formula down
            Selection.AutoFill Destination:=Range("CS2:CS" & lastrow), Type:=xlFillDefault
    
            'Calculations are set to manual, so there is the need to calculate
            Worksheets("sheet1").Calculate
            Range("CS2:CS" & lastrow).Copy
            Range("A2").PasteSpecial xlPasteValues
    
            'Delete extra column
            Range("CS:CS").Delete
            ...

+ 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. I need to format imported data so I can crunch the numbers
    By julienaas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2012, 03:11 PM
  2. Imported numbers will not format
    By pleiadeez7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-22-2011, 01:06 PM
  3. [SOLVED] Why are 1/2 my numbers imported as text and the rest as numbers?
    By KBear in forum Excel General
    Replies: 2
    Last Post: 04-21-2006, 08:45 AM
  4. Imported numbers change to dates
    By imajinaree in forum Excel General
    Replies: 3
    Last Post: 12-08-2005, 02:10 PM
  5. Replies: 9
    Last Post: 04-01-2005, 05:06 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