Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
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!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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!!!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Write a macro that hides rows based on empty cells Mac0001UK Excel Discussion (Misc queries) 3 March 10th 09 12:37 PM
How to Delete empty rows in excel in b/w rows with values Dennis Excel Worksheet Functions 3 August 28th 07 04:15 PM
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows Scott Excel Worksheet Functions 0 December 13th 06 01:25 AM
Cut and Paste macro based on criteria then delete empty rows samst Excel Programming 4 November 2nd 03 09:33 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"