I need to delete empty rows but since there are pretty many I want to do a loop. How do I do that? The entire column should be deleted if row 56 equals 0 and the columns are D to DS. Any suggestions?
I need to delete empty rows but since there are pretty many I want to do a loop. How do I do that? The entire column should be deleted if row 56 equals 0 and the columns are D to DS. Any suggestions?
Hi Edward,
Try:
'============>>
Sub Tester()
On Error GoTo 0
Range("D56:DS56").SpecialCells(xlCellTypeBlanks). _
EntireColumn.Delete
On Error GoTo 0
End Sub
'<<============
---
Regards,
Norman
"edward0380" <[email protected]> wrote
in message news:[email protected]...
>
> I need to delete empty rows but since there are pretty many I want to do
> a loop. How do I do that? The entire column should be deleted if row 56
> equals 0 and the columns are D to DS. Any suggestions?
>
>
> --
> edward0380
> ------------------------------------------------------------------------
> edward0380's Profile:
> http://www.excelforum.com/member.php...o&userid=29396
> View this thread: http://www.excelforum.com/showthread...hreadid=491107
>
Hi Edward,
I should have indicated that I have assumed that you want to delete
columns, as in the body of your post, rather than rows, as suggested in the
title and opening line.
---
Regards,
Norman
Thanks! You are right, I want to delete the columns... But if row 56 is equal to 0 will it not be deleted, how do I solve this?
Hi Edward,
Try:
'============>>
Sub Tester3()
Dim rng As Range
Dim i As Long
Set rng = Range("D56:DS56")
For i = rng.Columns.Count To 1 Step -1
With rng(i)
If .Value = 0 Then
.EntireColumn.Delete
End If
End With
Next i
End Sub
'<<============
---
Regards,
Norman
"edward0380" <[email protected]> wrote
in message news:[email protected]...
>
> Thanks! You are right, I want to delete the columns... But if row 56 is
> equal to 0 will it not be deleted, how do I solve this?
>
>
> --
> edward0380
> ------------------------------------------------------------------------
> edward0380's Profile:
> http://www.excelforum.com/member.php...o&userid=29396
> View this thread: http://www.excelforum.com/showthread...hreadid=491107
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks