hamistasty
Board Regular
- Joined
- May 17, 2011
- Messages
- 208
Rick rothstein made this code to help me delete columns with no values in them:
Was hoping to get some assistance editing it.
I want it to ALSO delete entire rows in the worksheet that do not have any values across the entire row. Currently the worksheet prints rows that have borders but no values. This would eliminate that problem.
But if there is a value in any cell of the entire row it keeps that row.
Code:
Sub DeleteAllBlankColumns()
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
On Error Resume Next
With Range("A" & (LastRow + 1) & ":CJ" & (LastRow + 1))
.FormulaR1C1 = "=IF(COUNTBLANK(R2C:R" & LastRow & "C)=" & (LastRow - 1) & ",""X"","""")"
.Value = .Value
.SpecialCells(xlCellTypeConstants).EntireColumn.delete
End With
End Sub
Was hoping to get some assistance editing it.
I want it to ALSO delete entire rows in the worksheet that do not have any values across the entire row. Currently the worksheet prints rows that have borders but no values. This would eliminate that problem.
But if there is a value in any cell of the entire row it keeps that row.