VBA MOD 01 nested loop - Loop through each cell value and each row

Option Explicit

Const startrow As Byte = 10

Dim lastrow As Long


Public Sub For_Next_loop_in_text()

    Dim i As Long 'for looping inside each cell

    Dim numfound As Long

    Dim textfound As String

    Dim myValue As String

    Dim r As Long 'looping through each rows

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 & VBA.Mid(myValue, i, 1)

       

       ElseIf Not IsNumeric(VBA.Mid(myValue, i, 1)) Then

       textfound = textfound & VBA.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

Public Sub Simple_For()

   Dim i As Long

    Dim myValue As Long

 lastrow = Range("A10").End(xlDown).Row

 For i = startrow To lastrow

 myValue = Range("F" & i).Value

    If myValue > 400 Then Range("F" & i).Value = myValue + 10

    If myValue < 0 Then Exit For

   End If

    Next i

 End Sub 




Comments

Popular posts from this blog

VBA01 Copy Resize Variably Sized Ranges

VBA MOD01 Passing Arguments to sub procedures (ByRef , By Val)

PY MOD01 Lecture 01