Microsoft Office Tutorials and References
In Depth Information
Extracting Numbers from a Text String
Extracting Numbers from a Text String
Using this procedure, you can extract only the numbers (digits from 0 to 9)
from a range that contains text strings.
Example file:
E038.xls
Scenario: When importing or pasting data from a different
source, some information that contains the desired numbers
can also include other characters, such as letters. In these
cases, where the Text-Import wizard cannot help, having a
way to extract only the numbers comes in very handy.
Exl
Figure 40 – Selecting Cells from Which to Extract Numbers
View the Appendix to learn how to store this procedure
in a Standard module.
Option Explicit¶
' * * * * *¶
Sub ExtractNumbers()¶
'Variable declaration¶
Dim Rng As Range¶
Dim Cll As Range¶
Dim Ans As Variant¶
'Select the cells to modify¶
'Continue when error occurs¶
On Error Resume Next¶
 
Search JabSto ::




Custom Search