Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default for every cell search identical in range, not whole column; how?

Hi expert,

To delete identical entries in cells of the first column (and delete
that row), I use a code which searches the whole column everytime. I
would like to speed things up.

If I sort on the second column (area code), the first column (postal
code) can be divided in multiple ranges:
A duplicate cell value, only occurs within the same range (area code)
as the reference cell value (e.g. a postal code/identical postal codes
only refer to one area code).


How should I adjust the following code to search part of the first
column (sorted on area code, second column) for duplicate postal
codes, instead of the whole column. I expect this to speed things up
significantly.

regards
ppeer

Sub DuplicateIDCorrection()
'Adjust next constant to your own needs
Const myColumn As String = "A"
Dim a, lngLastRow, T, RR As Long
Dim rng As Range
Dim cell As Range
Dim Found As Range
Dim blnFound As Boolean


lngLastRow = ActiveSheet.Cells(Rows.Count, myColumn).End(xlUp).row
Set rng = Range(myColumn & "1:" & myColumn & lngLastRow)
rng.Interior.ColorIndex = xlNone


T = 0

For Each cell In rng
If cell.Text < "" And IsError(cell.Value) < True Then
Set Found = rng.Find(cell.Value, LookAt:=xlWhole)
If Not Found Is Nothing Then

If Found.Address < cell.Address Then

RR = cell.row
T = T + 1
Debug.Print Found.Value, Found.Address,
cell.Address, T, RR, a
Rows(RR).Delete

End If
End If
End If
Next
Next a

'If blnFound = True Then MsgBox "Duplicates Found"


End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default for every cell search identical in range, not whole column; how?

Hi

Try to turn off calculation and screenupdating, I think it will speed your
macro more up than what you want to do:

Insert theese statements after the Dim statements:

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

And to turn them on again, insert this before End Sub:

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

Regards,
Per


"ppeer" skrev i meddelelsen
...
Hi expert,

To delete identical entries in cells of the first column (and delete
that row), I use a code which searches the whole column everytime. I
would like to speed things up.

If I sort on the second column (area code), the first column (postal
code) can be divided in multiple ranges:
A duplicate cell value, only occurs within the same range (area code)
as the reference cell value (e.g. a postal code/identical postal codes
only refer to one area code).


How should I adjust the following code to search part of the first
column (sorted on area code, second column) for duplicate postal
codes, instead of the whole column. I expect this to speed things up
significantly.

regards
ppeer

Sub DuplicateIDCorrection()
'Adjust next constant to your own needs
Const myColumn As String = "A"
Dim a, lngLastRow, T, RR As Long
Dim rng As Range
Dim cell As Range
Dim Found As Range
Dim blnFound As Boolean


lngLastRow = ActiveSheet.Cells(Rows.Count, myColumn).End(xlUp).row
Set rng = Range(myColumn & "1:" & myColumn & lngLastRow)
rng.Interior.ColorIndex = xlNone


T = 0

For Each cell In rng
If cell.Text < "" And IsError(cell.Value) < True Then
Set Found = rng.Find(cell.Value, LookAt:=xlWhole)
If Not Found Is Nothing Then

If Found.Address < cell.Address Then

RR = cell.row
T = T + 1
Debug.Print Found.Value, Found.Address,
cell.Address, T, RR, a
Rows(RR).Delete

End If
End If
End If
Next
Next a

'If blnFound = True Then MsgBox "Duplicates Found"


End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default for every cell search identical in range, not whole column; how?

thanks Per
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
Search/Filter for identical data richzip Excel Discussion (Misc queries) 3 April 13th 09 04:49 PM
Excel 2002: Can Vlookup search for identical references ? Mr. Low Excel Discussion (Misc queries) 1 July 16th 07 02:52 PM
Search Column for matches to a Range of Data, then modify cell [email protected] Excel Programming 1 June 11th 07 05:38 PM
mult. w/sheets need identical view when opening (range, mag, cell) Peter Setting up and Configuration of Excel 2 February 12th 07 12:28 AM
Loop through column headers to search from column name and get cell range Pie Excel Programming 9 December 29th 05 12:17 AM


All times are GMT +1. The time now is 07:16 PM.

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"