I have an excel spreadsheet that imports various information using a DDE link to another application. Fields sometimes error out, and these fields are evidenced by the presence of the pound sign "#" character. Sample errors are "#NA Fld", "#NA Calc", etc.
I want my macro to delete every row that contains any cell containing a pound sign.
My code to delete rows with the pound sign works great. Now I need an efficient way to create a "Do While" loop or something. I don't want to simply run the loop once for each row because processing time is so long (usually a couple thousand records per file).
Can you help me with efficient looping code to continue running the Find/Delete loop while # signs still exist on the spreadsheet?
Here's my current code:
Sub POUND()
' POUND Macro
' This macro finds and deletes all records that have error fields not populated_
' by the DDE Server. Error fields contain the # character.
Range("A1").Select
' locate cells containing the # character
Cells.Find(What:="#", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
' now delete that row
ActiveCell.EntireRow.Delete Shift:=xlUp
' now loop back through until all rows with error fields are deleted
End Sub
I want my macro to delete every row that contains any cell containing a pound sign.
My code to delete rows with the pound sign works great. Now I need an efficient way to create a "Do While" loop or something. I don't want to simply run the loop once for each row because processing time is so long (usually a couple thousand records per file).
Can you help me with efficient looping code to continue running the Find/Delete loop while # signs still exist on the spreadsheet?
Here's my current code:
Sub POUND()
' POUND Macro
' This macro finds and deletes all records that have error fields not populated_
' by the DDE Server. Error fields contain the # character.
Range("A1").Select
' locate cells containing the # character
Cells.Find(What:="#", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
' now delete that row
ActiveCell.EntireRow.Delete Shift:=xlUp
' now loop back through until all rows with error fields are deleted
End Sub