ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   locating numbers in a text string (https://www.excelbanter.com/excel-programming/275752-re-locating-numbers-text-string.html)

Tom Ogilvy

locating numbers in a text string
 
Sub Tester11()
Do While Not IsEmpty(ActiveCell)
sStr = ActiveCell.Text
x = 0
For i = 1 To Len(sStr)
sChr = Mid(sStr, i, 1)
If Asc(sChr) = 48 And Asc(sChr) <= 57 Then
x = x + 1
ActiveCell.Offset(0, x).Value = i
End If
Next
ActiveCell.Offset(1, 0).Select
Loop

End Sub

should do what you describe.

--
Regards,
Tom Ogilvy





mcdowell wrote in message
...
I am attempting to sepatate a single string of characters which includes
a middle

sector of numbers beginning and ending at different points. The
procedure needs to

analyze the current cell.... consider each character (loop using
LEN(Xcell)) compare

the character to see if it = "O" thru "9" .. then place the numeric
location point of the

character in a cell in the same row using an ActiveCell.Offset(0,x)
reference. If

multiple numeric characters are found in each string then entries need
to be made in

adjoining columns offset from the ActiveCell. The procedure needs then
to drop to the

line below and perform the process again. I have tried every thing I
know to create a

Sub... using nested loop etc... and I'm baffled.... any help out here??





All times are GMT +1. The time now is 05:38 PM.

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