+ Reply to Thread
Results 1 to 3 of 3

Convert a number formatted as text to a number in a macro

  1. #1
    Registered User
    Join Date
    06-20-2004
    Posts
    19

    Convert a number formatted as text to a number in a macro

    Anyone have a simple macro that converts a number in a cell that was formatted as text or proceeded by an apostrophe?

    Or a work around
    Coverting " 12345 - xyz"

    Selection.Copy
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveSheet.Paste
    ActiveCell.Offset(0, -1).Range("A1").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "=MID(RC[1],3,7)"
    ActiveCell.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues

    to "12345" such that a vlookup can then match this to "12345" that's formatted as a number already.

    Thanks for any and all help!

  2. #2
    Tom Ogilvy
    Guest

    Re: Convert a number formatted as text to a number in a macro

    If '12345

    is in the active Cell

    Sub aaa()
    ActiveCell.NumberFormat = "General"
    ActiveCell.Value = ActiveCell.Value

    End Sub

    --
    Regards,
    Tom Ogilvy


    "MACRE0" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Anyone have a simple macro that converts a number in a cell that was
    > formatted as text or proceeded by an apostrophe?
    >
    > Or a work around
    > Coverting " 12345 - xyz"
    >
    > Selection.Copy
    > ActiveCell.Offset(0, 1).Range("A1").Select
    > ActiveSheet.Paste
    > ActiveCell.Offset(0, -1).Range("A1").Select
    > Application.CutCopyMode = False
    > ActiveCell.FormulaR1C1 = "=MID(RC[1],3,7)"
    > ActiveCell.Select
    > Selection.Copy
    > Selection.PasteSpecial Paste:=xlPasteValues
    >
    > to "12345" such that a vlookup can then match this to "12345" that's
    > formatted as a number already.
    >
    > Thanks for any and all help!
    >
    >
    > --
    > MACRE0
    > ------------------------------------------------------------------------
    > MACRE0's Profile:

    http://www.excelforum.com/member.php...o&userid=10848
    > View this thread: http://www.excelforum.com/showthread...hreadid=478087
    >




  3. #3
    Registered User
    Join Date
    06-20-2004
    Posts
    19

    Ty

    I appreciate it, thanks.

+ 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