For Next Loop Problem
Posted by JAF on June 23, 2000 12:14 AM
I have a macro that goes through a column of data and replaces duplicate entries with the text string ---
I'm trying to create a For/Next Loop that will go through the data and for each cell where the value is --- to delete that row and move on to the next row.
The code I have is as follows:
Sub test_for_next_loop()
For Each Cell In Selection
If Cell.Value = "-----" Then
Cell.EntireRow.Delete Shift:=xlUp
End If
Next Cell
End Sub
This works (to an extent), but where I have consecutive instances of ---, it only replaces the first one. eg.
Client 1
---
---
Client 2
---
---
---
Client 3
---
becomes...
Client 1
---
Client 2
---
---
Client 3
What I want is...
Client 1
Client 2
Client 3
Any suggestions as to what I'm doing wrong?