VBA Convert Number Stored As Text To Number

VBA Convert Number Stored as Text to Number

VBA Convert Number Stored As Text To Number. Here the input value is number stored as number but in string format, we are converting this value as number. In the following article let us see an example. And also see the step by step instructions to run VBA code in the visual basic editor(VBE) window.

Convert Number Stored As Text To Number

Let us see an example VBA macro code how to Convert a range of Numbers Stored As Text To Numbers.

'Convert Number stored as text to Number
Sub VBAF1_Convert_Number_Stored_as_Text_to_Number()
    
    'Variable declaration
    Dim rngRange As Range
    
   'Define Range which you want to convert to range
    Set rngRange = ActiveSheet.Range("A1:A20")
    
    'Convert Number
    rngRange.Value = rngRange.Value
   
End Sub

Explanation: You can change defined range as per your requirement. When dealing with huge data we can use above specified process to convert numbers to numbers which are stored as text. We can also loop through each cell, but it takes longer time to execute. Please find below screen shot for your reference.

VBA Convert Numbers Stored As Text To Numbers
VBA Convert Numbers Stored As Text To Numbers

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays VBA Text Files VBA Tables

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers Blog

3 thoughts on “VBA Convert Number Stored As Text To Number”

  1. Other Useful conversations:

    Convert text to Number with ZERO Digits and Number convert ZERO Digits

    Sub ZERO_DIGIT()
     On Error Resume Next
     Dim rSelection As Range
     Set rSelection = rSelection
     rSelection.Select
     With Selection
      Selection.NumberFormat = "General"
      .Value = .Value
     End With
     rSelection.Select
      Selection.NumberFormat = "0"
     Set rSelection = Nothing
    End Sub
    

    Convert text to Number with TWO Digits and Number convert TWO Digits

    Sub TWO_DIGIT()
     On Error Resume Next
     Dim rSelection As Range
     Set rSelection = rSelection
     rSelection.Select
     With Selection
      Selection.NumberFormat = "General"
      .Value = .Value
     End With
     rSelection.Select
      Selection.NumberFormat = "0.00"
     Set rSelection = Nothing
    End Sub
    

    Convert text to Number with SIX Digits and Number convert SIX Digits

    Sub SIX_DIGIT()
     On Error Resume Next
     Dim rSelection As Range
     Set rSelection = rSelection
     rSelection.Select
     With Selection
      Selection.NumberFormat = "General"
      .Value = .Value
     End With
     rSelection.Select
      Selection.NumberFormat = "0.000000"
     Set rSelection = Nothing
    End Sub
    

Leave a Comment