I'm creating a simple loop that will go through a given range and every time the cell contains the work "UNIT" as the first 4 characters I want the macro to to organize the data. The problem is that I can't seem to get VBA to any actions to cells in the target range. here is the code I'm using:
Any suggestions would be greatly appreciated. Thanks.
Code:
Sub SortData()
Dim rDataTable As Range
Dim c As Range
Dim rTarget As Range
Dim x As Integer
Set rDataTable = Sheet1.Range("A21:A34")
Set rTarget = Sheet1.Range("H21")
x = 0
For Each c In rDataTable
Debug.Print Left(c.Value, 4)
Debug.Print c.Value
If Left(c.Value, 4) = "UNIT" Then
Sheet1.Cells(rTarget.Row + x, rTarget.Column) = c.Value
x = x + 1
Else: End If
Next c
End Sub
Any suggestions would be greatly appreciated. Thanks.