Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Thanks for all the help donated to this site. I have code that will delete all blank rows but I acutally need to only delete the row if I have more than 1. Following is the code I currently use for other projects: Private Sub DeleteEmptyRows() Dim LastRow As Long Dim r As Long LastRow = Sheets("Daily").UsedRange.Rows.Count LastRow = LastRow + Sheets("Daily").UsedRange.Row - 1 For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Any ideas. Thanks. Amy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One minor change:
Public Sub DeleteEmptyRows() Dim LastRow As Long Dim r As Long LastRow = Sheets("Daily").UsedRange.Rows.Count LastRow = LastRow + Sheets("Daily").UsedRange.Row - 1 For r = LastRow To 1 Step -1 If Application.CountA(Rows(r).Resize(2)) = 0 Then _ Rows(r).Delete Next r End Sub In article , Amy wrote: Hi, Thanks for all the help donated to this site. I have code that will delete all blank rows but I acutally need to only delete the row if I have more than 1. Following is the code I currently use for other projects: Private Sub DeleteEmptyRows() Dim LastRow As Long Dim r As Long LastRow = Sheets("Daily").UsedRange.Rows.Count LastRow = LastRow + Sheets("Daily").UsedRange.Row - 1 For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Any ideas. Thanks. Amy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Amy,
Change loop to look like this and it should work For r = LastRow To 2 Step -1 If Application.CountA(Rows(r - 1 & ":" & r)) = 0 Then Rows(r - 1 & ":" & r).Delete Next r "Amy" wrote: Hi, Thanks for all the help donated to this site. I have code that will delete all blank rows but I acutally need to only delete the row if I have more than 1. Following is the code I currently use for other projects: Private Sub DeleteEmptyRows() Dim LastRow As Long Dim r As Long LastRow = Sheets("Daily").UsedRange.Rows.Count LastRow = LastRow + Sheets("Daily").UsedRange.Row - 1 For r = LastRow To 1 Step -1 If Application.CountA(Rows(r)) = 0 Then Rows(r).Delete Next r End Sub Any ideas. Thanks. Amy |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete blank rows if more than one | Excel Discussion (Misc queries) | |||
Delete blank rows | Excel Discussion (Misc queries) | |||
How do I delete blank rows (rows alternate data, blank, data, etc | Excel Discussion (Misc queries) | |||
Delete all blank rows... | Excel Discussion (Misc queries) | |||
How to delete blank rows | Excel Discussion (Misc queries) |