Need help on deleting cells

shrek

Board Regular
Joined
Dec 16, 2005
Messages
244
I have data in a workbook which has blank cells in columns D and E. What im trying to find out is the a macro that will delete the row if the cells are blank in both columns D and E right the way down the workbook.
 
Try this on a copy of your sheet

Code:
Sub DelblankDE()
Dim LastRow As Long, i As Long
Application.ScreenUpdating = False
Application.Calculation = xlManual
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To LastRow
    Cells(i, 1).Value = Trim(WorksheetFunction.Clean(Cells(i, 1).Value))
Next i
Columns("A:A").SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
LastRow = Cells(Rows.Count, 4).End(xlUp).Row
For i = LastRow To 1 Step -1
    If IsEmpty(Cells(i, 4).Value) And IsEmpty(Cells(i, 5).Value) Then Rows(i).EntireRow.Delete
Next i
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
End Sub
 
Upvote 0

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Sorry to be a pain also but you need to find out what is in the cells in column A that appear to be blank but are not.
 
Upvote 0
How would I find that out, because as far as the workbook shows the cells are blank and I dont think there any hidden cells
 
Upvote 0
Did you adjust the reference ie A1 to whatever cell was actually 'blank'? Ascii 76 is a capital L, so I doubt you had this in your balnk cells, unless you have a white font applied.

So, say your blank cell is actually B23 then you need:

=CHAR(LEFT(B23))
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,795
Members
449,468
Latest member
AGreen17

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top