# Help with if statements!

#### CC268

##### Active Member
This is driving me a bit nuts...seems like this should be really easy so I am trying to figure out the code on my own here.

I want to use the .Clear command to simply Clear a row if there are NO VALUES in columns A through I (there will be values in J and K that I want cleared if the condition that there are no values in A through I are met).

 A B C D E F G H I J K safsd sfsd sfsd sdfs sdfs sdsd sdsd sdsd sdsd sdsd sdsd sds sdsd

<tbody>
</tbody>

So I wrote a bunch of mumbo jumbo above - but you can see that I want to CLEAR the contents of rows 2 and 4 because those rows do not contain any values in columns A through I.

Is this a lot harder to do than I think it should be?

### Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

#### Steve_R

##### Active Member
Do you mean you wish to delete rows that are blank in all cells in columns A-I? If so, the following macro will do it

Code:
``````Sub DeleteBlankRows()

lRow = ActiveSheet.UsedRange.Count

Application.ScreenUpdating = False
For i = lRow To 2 Step -1

If Application.WorksheetFunction.CountA(Range("A" & i & ":I" & i)) = 0 Then 'if everything blank
Rows(i).Delete
End If
Next
Application.ScreenUpdating = True
End Sub``````

If you don't know how to use a macro
(with the required sheet open)
1) use keystroke combination [Alt]/[F11]
2) Create a new regular module using keystroke combination [Alt]//[M]
3) Paste the code
4) Press F5 to run the code

Make sure you test on a copy first.

EDIT: Alternatively, use a multi-colunm sort to get blank rows into a block and manually delete the blank rows.

Last edited:

#### CC268

##### Active Member
Thanks a lot I will try this when I am at work tomorrow! I didn't think about doing a multi column sort but that probably would have been very easy lol...

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,311
Messages
5,836,583
Members
430,438
Latest member
David Gr

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back