Excel Sheet with a Macro is Getting Slower As the Entries Increase

excelnow

Board Regular
Joined
Nov 17, 2009
Messages
106
Hi,

I have an excel sheet with a macro that checks if my latest entry is already on the column and deletes it automatically if it exists.

There are three columns: website URL, email address and 1-word note.

I have about 1000 rows of data at the moment and it is getting slower as I input more rows. This sheet will keep growing and I guess it will be very difficult to enter new data soon.

Here is the macro I use for duplicate detection and deletion of the last entry if it exists:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

Dim Rng As Range, Dn As Range
    If Target.Count <> 1 Then Exit Sub
        Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
            If Application.CountIf(Rng, Target) > 1 Then
                Selection.ClearContents
            End If
End Sub

Until about 500-600 entries, it was working really fast, but now, when I enter new data into that column, it takes about 2 seconds.

I deleted the macro and added a conditional formating rule on Column A and it highlights the last entry if it already exists on the column. Well, that's fast, but I need to delete it manually now. This was the beauty of the macro.

Do you have any comments on this? It seems I will have to go with no macro solution (conditional formating).
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
If Target.Count <> 1 Then Exit Sub
With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    .EnableEvents = False
End With
Set Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
If Application.CountIf(Rng, Target) > 1 Then
    Target.ClearContents
End If
With Application
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    .EnableEvents = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top