I am trying to set up a macro to delete empty rows I have tryed a few things but this is the only code which seems to actully run through it.
How do I set up a loop so it will start at C20 for example and work up the sheet till C2
If ActiveSheet.Range("c20") = "" Then ActiveSheet.Rows("20:20").Select Selection.Delete Shift:=xlUp End If
Try this code -
lastrow=range("C" & rows.count).end(xlup).row for i = lastrow to 2 step -1 'your if code here next i
Try this.
If it works then please mark the post as SOLVED
Sub DeleteEmpty() Dim i As Integer Dim shtTHIS As Worksheet Dim c As Range Dim chk As Boolean Set shtTHIS = ThisWorkbook.ActiveSheet For i = shtTHIS.UsedRange.Rows.Count To 1 Step -1 chk = False For Each c In shtTHIS.Range("A" & i, "Z" & i) If VBA.Len(c) > 0 Then chk = True Next If chk = False Then shtTHIS.Range("A" & i).EntireRow.Delete Next End Sub
Another option:
Sub DelEmptyRows() Range("C2:C20").SpecialCells(xlCellTypeBlanks).EntireRow.Delete End Sub
Nilem for some reason that will not work the first part of the macro is copying and pasting text from a table in another workbook and this seems to be making the macro think there is data in the blank cess but there is not
GrahamRoss, Did you try mine above?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks