View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default 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!!!