Error - End If Without Block

  • Thread starter Thread starter Gauthier
  • Start date Start date
G

Gauthier

Hi There...for the likes of me, i just can't get this to work!
Can anyone help?
Sandi

the following is a snippet of my module that won't work - i've already
declared "Dim X As Long" in a previous procedure - and incidentially, i
started the range with column C, because the last two cells in column A are
blank:

' CODE TO DELETE ROWS WHICH CONTAIN BLANK VALUES IN COLUMN A, AND "FALSE"
IN COLUMN I
For X = Range("C65536").End(xlUp).Row To 1 Step -1
If Range("A" & X) = "" Or _
Range("I" & X) = "FALSE" Then _
Range("A" & X).EntireRow.Delete
End If
Next
 
since you made your If statement a single line IF statement, you don't need
an End IF

For X = Range("C65536").End(xlUp).Row To 1 Step -1
If Range("A" & X) = "" Or _
Range("I" & X) = "FALSE" Then _
Range("A" & X).EntireRow.Delete
Next
 
Hi
try:
' CODE TO DELETE ROWS WHICH CONTAIN BLANK VALUES IN COLUMN A, AND
"FALSE"
IN COLUMN I
For X = Range("C65536").End(xlUp).Row To 1 Step -1
If Range("A" & X) = "" Or _
Range("I" & X) = "FALSE" Then
Range("A" & X).EntireRow.Delete
End If
Next
 
Your problem is here is with the underscore before the Delete. Get rid of it
and you are golden... or get rid of the end if. Either way will do

If Range("A" & X) = "" Or _
Range("I" & X) = "FALSE" Then
Range("A" & X).EntireRow.Delete
End If

or

If Range("A" & X) = "" Or _
Range("I" & X) = "FALSE" Then _
Range("A" & X).EntireRow.Delete

Hope this helps...
 
Thanks Tom...
i ran the code, and for some reason, rows in col "I" which have "FALSE" in
them are not deleting...
the entire column "I" contains primarily numbers and is formatted as a
NUMBER - is that what's causing the problem??
Sandi
 
You are checking for the string "FALSE". If they have the boolean value
False, you might want to check for that instead:

For X = Range("C65536").End(xlUp).Row To 1 Step -1
If Range("A" & X) = "" Or _
Range("I" & X) = FALSE Then _
Range("A" & X).EntireRow.Delete
Next
 
...Blank values in Column A, AND "False" in column i...

In addition, your note says to use "And", but your code is using "Or."
Could that be another source of your problem?

HTH
Dana DeLouis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top