Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Delete Blank Rows

Hi,

Wonder if someone could help me please.

I have a spreadsheet with various rows of data in. There are however rows
that are blank.

Can anyone point me in the right direction as to how I may write a macro
that searches from row 1 to 65536 and checks that if the cells in columns A:Z
are blank it deletes that row.

Thanks very much

Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete Blank Rows

Test this one Chris

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Range(.Cells(Lrow, "A"), _
.Cells(Lrow, "Z"))) = 0 Then .Rows(Lrow).Delete

Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"ir26121973" wrote in message ...
Hi,

Wonder if someone could help me please.

I have a spreadsheet with various rows of data in. There are however rows
that are blank.

Can anyone point me in the right direction as to how I may write a macro
that searches from row 1 to 65536 and checks that if the cells in columns A:Z
are blank it deletes that row.

Thanks very much

Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Delete Blank Rows

Ron,

This works a treat, thanks very much.

Sorry it's taken a while to reply. Trying to get this diabolical web site to
work.

Once again many thanks

Chris

"Ron de Bruin" wrote:

Test this one Chris

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Range(.Cells(Lrow, "A"), _
.Cells(Lrow, "Z"))) = 0 Then .Rows(Lrow).Delete

Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"ir26121973" wrote in message ...
Hi,

Wonder if someone could help me please.

I have a spreadsheet with various rows of data in. There are however rows
that are blank.

Can anyone point me in the right direction as to how I may write a macro
that searches from row 1 to 65536 and checks that if the cells in columns A:Z
are blank it deletes that row.

Thanks very much

Chris




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete Blank Rows

Hi Chris

Use Outlook Express to connect to the newsgroups
Much faster and better


--
Regards Ron de Bruin
http://www.rondebruin.nl



"ir26121973" wrote in message ...
Ron,

This works a treat, thanks very much.

Sorry it's taken a while to reply. Trying to get this diabolical web site to
work.

Once again many thanks

Chris

"Ron de Bruin" wrote:

Test this one Chris

Sub Example1()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

Firstrow = ActiveSheet.UsedRange.Cells(1).Row
Lastrow = ActiveSheet.UsedRange.Rows.Count + Firstrow - 1

With ActiveSheet
.DisplayPageBreaks = False
For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Range(.Cells(Lrow, "A"), _
.Cells(Lrow, "Z"))) = 0 Then .Rows(Lrow).Delete

Next
End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"ir26121973" wrote in message ...
Hi,

Wonder if someone could help me please.

I have a spreadsheet with various rows of data in. There are however rows
that are blank.

Can anyone point me in the right direction as to how I may write a macro
that searches from row 1 to 65536 and checks that if the cells in columns A:Z
are blank it deletes that row.

Thanks very much

Chris






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
Delete blank rows if more than one Kjellk Excel Discussion (Misc queries) 5 June 10th 09 06:17 AM
Delete blank rows JakeShipley2008 Excel Discussion (Misc queries) 2 October 30th 08 02:18 AM
How do I delete blank rows (rows alternate data, blank, data, etc ncochrax Excel Discussion (Misc queries) 2 June 27th 07 04:40 AM
Delete blank row only if 2 consecutive blank rows Amy Excel Programming 2 October 21st 04 05:24 PM
help delete blank rows Cletus Stripling Excel Programming 5 July 25th 03 08:47 PM


All times are GMT +1. The time now is 09:10 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"