Delete Rows Based on Condition
-
-
-
Re: Declaring Variables
Samuels, I edited your post to add code tags. Please do not omit in the future.
-
-
Re: Declaring Variables
Thanx a lot mate!
-
Re: Declaring Variables
Mate,
Do I need an Else argument in this code for those situations where "A" is not = ""?
Thank you.
-
-
Re: Declaring Variables
I dunno. What else do you want to do?
-
Re: Declaring Variables
Quote from shgTry this:
I found a little bitty bug in that. If you have two adjacent rows with a blank in Column A, the loop skips over the second one, because it shifted up. Try this:
Code
Display MoreSub DeleteBlankRowInColumnA() 'this macro scrolls down Column A if the cell is empty the row is deleted. Dim i As Long Const max As Long = 142 Dim deletions As Long deletions = 0 i = 1 Do While i <= 142 If Cells(i, "A") = "" Then Cells(i, "A").Delete shift:=xlUp deletions = deletions + 1 If deletions > 142 Then Exit Do End If Else i = i + 1 End If Loop End Sub
Note that if the last row you check has a blank line, you will just keep deleting forever unless you put a cap on how many deletions you are willing to do. In this case I set the max number of deletions the same as the number of rows to check.
-
-
-
-
-
Re: Declaring Variables
samuels90, *
PM me if you decide to read and abide by them.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!