I have a worksheet that contains data in column A. I'd like to loop through each cell (beginning at cell A5) and paste the data that meets criteria and is non-blank in column C (starting at C5). I also want column C to be continuous data, so it'll post the next value after the last nonblank cell in the column.
IF criteria: cell value starts with "AA" or "BA"
And then I'd like the sub to start once it reaches a cell with value "Stop"
So column A would go somewhat like this:
AA1 (A5)
*blank*
AA2
BA3
Random values
BA4
Stop
Results, starting in C5:
AA1
AA2
BA3
BA4
This is what I have so far, which gets the values but based on criteria but doesn't consolidate rows when pasting:
IF criteria: cell value starts with "AA" or "BA"
And then I'd like the sub to start once it reaches a cell with value "Stop"
So column A would go somewhat like this:
AA1 (A5)
*blank*
AA2
BA3
Random values
BA4
Stop
Results, starting in C5:
AA1
AA2
BA3
BA4
This is what I have so far, which gets the values but based on criteria but doesn't consolidate rows when pasting:
VBA Code:
Sub Help_Plz ()
Dim i As Long
For i = 5 To 50 'Ideally i'd like this to expand to the last row, or "Stop"
If Left(Range("A" & i), 2) = "AA"
Or Left(Range("A" & i), 2) = "BA" Then
Range ("A" & i).Copy
Range ("C" & i).PasteSpecial xlPasteValues
Else: GoTo Skip
End If
Skip:
Next i