Results 1 to 5 of 5

Simple VBA code to convert text to number (simplify/fix current code)

Threaded View

  1. #1
    Registered User
    Join Date
    10-26-2018
    Location
    NY
    MS-Off Ver
    2010
    Posts
    3

    Simple VBA code to convert text to number (simplify/fix current code)

    I tried to covert the text to number under range A:A for every worksheet in the workbook using some vba code.

    Capture.PNG

    Did some search online and this is my current code:

    Sub Convert_Text_To_Number()
    Dim Sh As Worksheet
    For Each Sh In ThisWorkbook.Worksheets
    If Sh.Visible = True Then Sh.Activate
    Dim rBig As Range, r As Range, v As Variant
    Set rBig = Range("A:A")
    For Each r In rBig
    v = r.Value
    If Not IsError(v) Then
    If v <> "" And r.HasFormula = False Then
    If IsNumeric(v) Then
    r.Clear
    r.Value = v
    End If
    End If
    End If
    Next r
    Next Sh
    End Sub

    The code works but every time it runs, it freezes the excel for quite a few seconds. I think something might be wrong or the code can be simplified?
    Please help take a look and suggest some better solution.

    Thank you very much

    Ken
    Last edited by kenenthpaul0401; 10-26-2018 at 10:49 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Convert from text to number code Macro
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-25-2017, 02:26 PM
  2. Is there a VBA code to simplify (linear) algebraic expressions? (using text input)
    By tahi.laci in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2015, 06:11 PM
  3. Simple Ifelse code to return %change between current and previous purchases shows #value
    By -DoesNotCompute- in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2015, 08:55 PM
  4. Convert Cell Formula to Convert Text to VBA Code
    By PY_ in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2014, 05:51 PM
  5. Convert Text to a Number - VB Code Needed
    By SEOT in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2008, 06:21 PM
  6. Code to convert text input to a number
    By FCC in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2006, 05:00 AM
  7. [SOLVED] Convert text strings to a code or number
    By MaxNY23 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-23-2006, 06:50 PM

Tags for this Thread

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