Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert Text to Number (VBA)

    Is there any code that can convert text store in a cell to a number?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert Text to Number (VBA)

    Please be specific.

    Is this in Excel, or in Word, or ...? You mention 'cell' but not which application you are using.

    Do you want to convert "thirty one" to 31, or do you want something else?

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    132
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert Text to Number (VBA)

    The application is excel.

    I have imported data and it's being stored as text. ie. 10

    Thanks

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Convert Text to Number (VBA)

    There are several methods to do this without VBA, for example:

    Select a column of "text numbers".
    Select Data | Text to Columns...
    Click "Delimited", then click Finish.

    or

    Select an empty cell.
    Copy it to the clipboard.
    Select a range of "text numbers".
    Select Edit | Paste Special...
    Click the "Add" option, then click OK.

    If you want to use a macro, here is one:

    Sub Text2Number()
    Dim oCell As Range
    For Each oCell In Selection
    oCell.Value = oCell.Value
    Next oCell
    Set oCell = Nothing
    End Sub

Posting Permissions

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