ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Define Range in Deleting Empty Rows (https://www.excelbanter.com/excel-programming/285821-define-range-deleting-empty-rows.html)

HamishM[_3_]

Define Range in Deleting Empty Rows
 
Hi,
Am using the following code to remove empty rows. How can i set th
rows to be checked eg. A15:A2500


Sub DeleteBlankRows1()

Dim i As Long

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False

For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub


thanks,
Hamis

--
Message posted from http://www.ExcelForum.com


Dave Peterson[_3_]

Define Range in Deleting Empty Rows
 
If you know the range:

Option Explicit
Sub DeleteBlankRows1A()

Dim i As Long
Dim rng As Range

Set rng = ActiveSheet.Range("a15:a2500") ' or Selection

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False

For i = rng.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(rng.Rows(i)) = 0 Then
rng.Rows(i).EntireRow.Delete
End If
Next i

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub



HamishM wrote:

Hi,
Am using the following code to remove empty rows. How can i set the
rows to be checked eg. A15:A2500

Sub DeleteBlankRows1()

Dim i As Long

With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False

For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With
End Sub

thanks,
Hamish

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson



All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com