ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Macros (https://www.excelbanter.com/new-users-excel/61567-macros.html)

Nimesh Shastri

Macros
 
Dear Sir

How can I make a macro which will delete all the Blank rows from a data
before pasting it in Excel

Bob Phillips

Macros
 
Sub Test()
Dim iLastRow As Long
Dim i As Long
Dim rng As Range

iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To iLastRow
If Application.CountA(Rows(i)) = 0 Then
If rng Is Nothing Then
Set rng = Rows(i)
Else
Set rng = Union(rng, Rows(i))
End If
End If
Next i

If Not rng Is Nothing Then
rng.Delete

End If

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Nimesh Shastri" <Nimesh wrote in message
...
Dear Sir

How can I make a macro which will delete all the Blank rows from a data
before pasting it in Excel






All times are GMT +1. The time now is 10:08 AM.

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