ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   extract numbers from a string (https://www.excelbanter.com/excel-worksheet-functions/198031-extract-numbers-string.html)

Dave

extract numbers from a string
 
Hello,

We import strings of numbers into a spreadsheet looking like
this:-

12Rev999,nextrev456
124Rev8888,nextrev1234

In practice the numbers can be any length from 1 to 4 numbers and there are
always three groups. I need to extract these numbers which are in Column A to
Column C
nearly forgot to mention the numbers in this format are text and I need them
as numbers.

Hope you can help.

D

Lars-Åke Aspelin[_2_]

extract numbers from a string
 
On Thu, 7 Aug 2008 12:37:01 -0700, Dave
wrote:

Hello,

We import strings of numbers into a spreadsheet looking like
this:-

12Rev999,nextrev456
124Rev8888,nextrev1234

In practice the numbers can be any length from 1 to 4 numbers and there are
always three groups. I need to extract these numbers which are in Column A to
Column C
nearly forgot to mention the numbers in this format are text and I need them
as numbers.

Hope you can help.

D


Assuming your strings are in column D you may try the following
formulas in cells A1, B1, and C1 respectivey:

=LEFT(D1,FIND("Rev",D1)-1)+0

=MID(D1,FIND("Rev",D1)+3,FIND("nextrev",D1)-FIND("Rev",D1)-4)+0

=RIGHT(D1,LEN(D1)-FIND("nextrev",D1)-6)+0

Hope this helps / Lars-Åke


Duke Carey

extract numbers from a string
 
if you ALWAYS have "Rev" and ",nextrev" as the only alpha characters, then

=SUBSTITUTE(SUBSTITUTE(A1,"Rev",""),",nextrev","") *1

will work


"Dave" wrote:

Hello,

We import strings of numbers into a spreadsheet looking like
this:-

12Rev999,nextrev456
124Rev8888,nextrev1234

In practice the numbers can be any length from 1 to 4 numbers and there are
always three groups. I need to extract these numbers which are in Column A to
Column C
nearly forgot to mention the numbers in this format are text and I need them
as numbers.

Hope you can help.

D


Otto Moehrbach[_2_]

extract numbers from a string
 
Dave
If all else fails, this little macro will do it for you. I assumed your
data is in Column A starting in A1. This macro displays a message box
showing you the number for each entry in Column A. HTH Otto
Sub GetNums()
Dim rColA As Range
Dim i As Range
Dim c As Long
Dim Nums As Long
Set rColA = Range("A1", Range("A" & Rows.Count).End(xlUp))
For Each i In rColA
c = 1
Nums = 0
For c = 1 To Len(i)
If IsNumeric(Mid(i, c, 1)) Then
Nums = --(Nums & Mid(i, c, 1))
End If
Next c
MsgBox Nums
Next i
End Sub
"Dave" wrote in message
...
Hello,

We import strings of numbers into a spreadsheet looking like
this:-

12Rev999,nextrev456
124Rev8888,nextrev1234

In practice the numbers can be any length from 1 to 4 numbers and there
are
always three groups. I need to extract these numbers which are in Column A
to
Column C
nearly forgot to mention the numbers in this format are text and I need
them
as numbers.

Hope you can help.

D




All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com