LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA - remove all empty rows in a worksheet

Option Explicit
Public Sub Tester2a()
Dim WB As Workbook
Dim SH As Worksheet
Dim LastRow As Long
Dim FirstRow As Long
Dim iRow As Long

'set it up to point at the correct workbook/worksheet
Set WB = ActiveWorkbook '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE

With SH
'lastrow is the same as the row number for the cell you go
'to when you hit ctrl-end manually.
LastRow = .Cells.SpecialCells(xlCellTypeLastCell).Row

'just a stopping point.
'if you had a bunch of headers (some empty rows), you
'could ignore them by changing this to a larger number
FirstRow = 1

'start at the lastrow and go up the rows (step -1 is up)
For iRow = LastRow To FirstRow Step -1
'if you see anything (formulas or values in that row)
'then =counta() will be 0
If Application.CountA(.Rows(iRow)) = 0 Then
'but if it no cells are filled in, then
'delete that row
.Rows(iRow).Delete
End If
Next iRow
End With

End Sub

juergenkemeter wrote:

Hi!
Dave, your first code sample does the necessary. Could you shortly
explain how your code works?

Thanks to you both for your help!
Juergen

--
juergenkemeter
------------------------------------------------------------------------
juergenkemeter's Profile: http://www.excelforum.com/member.php...o&userid=25248
View this thread: http://www.excelforum.com/showthread...hreadid=499951


--

Dave Peterson


 
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
how to remove empty rows? Joe Excel Discussion (Misc queries) 2 January 6th 08 05:10 PM
How do I remove empty Rows Rodders Excel Discussion (Misc queries) 2 January 12th 07 12:04 PM
Remove empty rows in excel? Clbmgr Excel Discussion (Misc queries) 6 December 2nd 04 02:02 AM
remove all blank or empty rows [email protected] [email protected] Excel Programming 8 January 18th 04 07:55 PM
Remove empty rows Kaj Pedersen Excel Programming 15 November 2nd 03 07:22 PM


All times are GMT +1. The time now is 12:36 PM.

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"