Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 577
Default Slow running code

I am trying to delete or clear out duplicate rows based on a few cells that
match. The cells other than those in the B, C & M columns may not match.
The below code works but runs very slowly (takes about 5 seconds per row).
Anyone know of a better (faster) way?

For RowIndex = 2 To 2000
If Range("B" + CStr(RowIndex)) = Range("B" + CStr(RowIndex + 1)) And _
Range("C" + CStr(RowIndex)) = Range("C" + CStr(RowIndex + 1)) And _
Range("M" + CStr(RowIndex)) = Range("M" + CStr(RowIndex + 1)) Then
Range("A" + CStr(RowIndex) + ":" + "Z" + CStr(RowIndex)) = ""
End If
Next

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Slow running code


turn off calculation and screenupdating before the code and then turn it back on
after it runs

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

' your code


With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
--


Gary


"Scott" wrote in message
...
I am trying to delete or clear out duplicate rows based on a few cells that
match. The cells other than those in the B, C & M columns may not match.
The below code works but runs very slowly (takes about 5 seconds per row).
Anyone know of a better (faster) way?

For RowIndex = 2 To 2000
If Range("B" + CStr(RowIndex)) = Range("B" + CStr(RowIndex + 1)) And _
Range("C" + CStr(RowIndex)) = Range("C" + CStr(RowIndex + 1)) And _
Range("M" + CStr(RowIndex)) = Range("M" + CStr(RowIndex + 1)) Then
Range("A" + CStr(RowIndex) + ":" + "Z" + CStr(RowIndex)) = ""
End If
Next



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
here is my code...it's running a bit slow though..any ideas to make it more efficient? thanks Zarlot531 Excel Programming 2 April 30th 07 02:12 PM
Workbook running VERY slow kippers Excel Discussion (Misc queries) 1 February 1st 07 03:27 PM
Slow Running Code to Hide Blank Rows Aaron Excel Programming 3 January 10th 07 03:17 AM
code running super slow... gaba Excel Programming 3 November 20th 04 02:35 AM


All times are GMT +1. The time now is 05:09 AM.

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

About Us

"It's about Microsoft Excel"