VBA MOD01 For Next nested loop (loop through text and cells)
● Loop through text and extract text and numbers to separate cells
Sub For_next_loop_in_text()
Dim i As Long 'For looping inside each cell
Dim numfound As Long
Dim textfound As String
Dim r As Long 'For looping through each row
Dim lastrow As String
lastrow = Range("A" & Rows.Count).End(xlUp).Row
For r = StartRow To lastrow
myValue = Range("A" & r).Value
For i = 1 To VBA.Len(myValue)
If IsNumeric(VBA.Mid(myValue, i, 1)) Then
numfound = numfound & Mid(myValue, i, 1)
ElseIf Not IsNumeric(VBA.Mid(myValue, i, 1)) Then
textfound = textfound & Mid(myValue, i, 1)
End If
Next i
Range("H" & r).Value = numfound
Range("I" & r).Value = textfound
numfound = 0
textfound = ""
Next r
End Sub
Comments
Post a Comment