LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Loop thru cells & isolate numeric string

Hi Ray,

Am Wed, 8 Apr 2015 06:01:50 -0700 (PDT) schrieb Ray:

Thanks so much, works perfectly! Now I'll kill the rest of my morning dissecting the code to figure out how it works ... ;)


you are welcome.
You also can do it with Regular Expressions:

Sub Test()
Dim LRow As Long, i As Long
Dim varData1 As Variant, varData2 As Variant
Dim ptrn1 As String, ptrn2 As String
Dim re As Object

'Set a reference to Microsoft VBScript Regular Expressions
With ActiveSheet
LRow = .Cells(Rows.Count, "J").End(xlUp).Row
varData1 = .Range("J19:J" & LRow)
varData2 = .Range("J19:J" & LRow)

ptrn1 = "\d|\(|\)"
ptrn2 = "\D"

Set re = New RegExp
re.Pattern = ptrn1
re.IgnoreCase = False
re.Global = True

For i = 1 To UBound(varData1)
varData1(i, 1) = WorksheetFunction.Trim(re.Replace(varData1(i,
1), ""))
Next

re.Pattern = ptrn2
re.IgnoreCase = False
re.Global = True

For i = 1 To UBound(varData2)
varData2(i, 1) = WorksheetFunction.Trim(re.Replace(varData2(i,
1), ""))
Next

.Range("J19").Resize(UBound(varData1)) = varData1
.Range("K19").Resize(UBound(varData2)) = varData2
End With

End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through cells to find a string and copy/paste the matching column to a new wkbk KeriM Excel Programming 3 September 21st 12 10:40 PM
How can I isolate the last two words in a text string? Steve Gibbs Excel Discussion (Misc queries) 7 November 28th 08 11:23 PM
isolate date from a text string into another cell Tacrier Excel Discussion (Misc queries) 5 October 11th 08 12:00 AM
Loop through range of cells, string search, take action [email protected] Excel Programming 1 November 3rd 06 12:56 PM
How do I loop a range of cells until I get a numeric value? ManKind New Users to Excel 1 June 4th 06 06:48 AM


All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"