![]() |
How do I write a macro to delete all rows from the first empty ro.
Does anyone know how I could write a macro to delete all rows from the first
empty row to row 2000 please? If I use the control+shift+down arrow and then go down one cell, the macro programmes the precise cell reference -- but this changes on datasheets with different amounts of data. HELP PLEASE!!! |
How do I write a macro to delete all rows from the first empty ro.
Try this code.
Sub DeleteTo2000() Dim rng As Range Dim wks As Worksheet Set wks = ActiveSheet Set rng = wks.Range("A1").End(xlDown).Offset(1, 0) Range(rng, wks.Range("A2000")).EntireRow.Delete End Sub HTH "Jon M" wrote: Does anyone know how I could write a macro to delete all rows from the first empty row to row 2000 please? If I use the control+shift+down arrow and then go down one cell, the macro programmes the precise cell reference -- but this changes on datasheets with different amounts of data. HELP PLEASE!!! |
How do I write a macro to delete all rows from the first empty ro.
set rng = Range("A1").End(xldown)(2)
if rng.row < 2001 then rng.resize(2001-rng.row,1).Entirerow.Delete End If -- Regards, Tom Ogilvy "Jon M" <Jon wrote in message ... Does anyone know how I could write a macro to delete all rows from the first empty row to row 2000 please? If I use the control+shift+down arrow and then go down one cell, the macro programmes the precise cell reference -- but this changes on datasheets with different amounts of data. HELP PLEASE!!! |
All times are GMT +1. The time now is 09:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com