LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
slo slo is offline
external usenet poster
 
Posts: 3
Default Can anyone help me convert to more efficient code?

I borrowed this sub from a site I ran across but it takes about 25-30
seconds on a P4. I know there is a better way, but I don't have the
brain to code. I would appreciate very much an offer for any
improvements.

I am trying to remove all rows where the F column has no value.

Thank you all.
Dan

Sub DeleteEmptyRowsWhereFIsEmpty()
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 IsError(.Cells(Lrow, "F").Value) Then
'Do nothing, This'll avoid a error if there is a error
in the cell

ElseIf .Cells(Lrow, "F").Value = "" Then .Rows(Lrow).Delete
'This will delete each row with the blan value in
Column F, case sensitive.

End If
Next
End With

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

End Sub

 
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 can I make this code more efficient? Sethaholic[_27_] Excel Programming 1 August 1st 06 05:15 PM
need to make code more efficient (if possible) Lilivati Excel Programming 8 July 7th 06 07:50 PM
Efficient Code GregR Excel Programming 7 June 27th 05 04:09 PM
More Efficient code than this thom hoyle Excel Programming 14 May 11th 05 07:40 AM
More efficient code Rob Bovey Excel Programming 1 July 9th 03 04:46 AM


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