Column Q contains numbers, and string"Group By". Column R contains both Names (against the cells containing string), and part numbers in other rows. I want to copy only the names from column R, if column Q is value= "Group By". I have written the following code.
Sub WithDoWhileAndIf()
Range("Q2").Activate
Do While ActiveCell.Value <> ""
For i = Q2 To Q1000
If ActiveCell.Value = "Group By" Then
ActiveCell.Offset(0, 1).Copy
ActiveCell.Offset(0, -1).PasteSpecial Paste:=xlValue
ActiveCell.Offset(0, 1).Activate
ActiveCell.Offset(1, 0).Activate
End If
Next
Loop
End Sub
It copies only the first row value, and then the selection is not moving down in column Q. Can anyone please help me to rectify the error?
Thanks a lot
GM