Can I improve a worboook to work more efficently

ghrek

Active Member
Hi

I have a workbook that compares missing data and duplicates and put in column F if missing and column N if duplicate.

At present it looks up to line 9999 and its extremely slow and sometimes misses missing and duplicated data. My data will not always go to line 9999 and wondered if I can calculate upto the last inputted line of which will differ.

Also wondered if it can be made faster at all. Dont matter how it is as long as it compares for duplicates and missing data. File enclosed so you can sort of get a better idea.

https://1drv.ms/x/s!AlFxNGHiZueY_RGveqJW0JF7jTbo?e=ZCbgMf

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

gallen

Well-known Member
Many of the people who COULD help here may not be able to as, like me, they can't access external links from work. If you post the code using the code tags, you stand a better chance of help. I assume it's done in VBA?

ghrek

Active Member
Right oh and hope this helps..

In column F I have this formula that looks in columns J-M to see if missing from there and if so it marks it "MISSING" in column F

=IF([@Source]="","",IF(ISNA(MATCH([@ID]&"|"&[@Field2]&"|"&[@Date]&"|"&[@Value],INDEX(\$J\$2:\$J\$9999&"|"&\$K\$2:\$K\$9999&"|"&\$L\$2:\$L\$9999&"|"&\$M\$2:\$M\$9999,0),0)),"Missing",""))

Then in column N i have the formula below that looks all down for duplicated entries in columns J-M

=IF(I2="","",IF(COUNTIFS(\$J\$2:\$J\$9999,J2,\$K\$2:\$K\$9999,K2,\$L\$2:\$L\$9999,L2,\$M\$2:\$M\$9999,M2)>1,"Duplicate",""))

Issue im having it very slow and not always picking up duplicates and missing items. Also I have at present it looking all the way down to line 9999 as when I run it there are always a different number of entries and thus cannot really set a specified number.

Last edited:

gallen

Well-known Member
Ah, it's formulaic. Many experts on formulas here. Sadly I'm not one of them.

I'm sure someone will pick this up and help. Good luck.

ghrek

Active Member

I think im going to tackle this with 2 seperate macros

I found this one and amended but it keeps telling me a compile error invalid outside procedure on this line.

lastRow = Sheet1.Range("J2").CurrentRegion.Rows.Count
For rowNo = 2 To lastRow

whole macro below

Dim lastRow As Integer, compRow As Integer, rowNo As Integer4

lastRow = Sheet1.Range("J2").CurrentRegion.Rows.Count
For rowNo = 2 To lastRow

For compRow = rowNo + 1 To lastRow

If Range("J" & compRow) = Range("J" & rowNo) Then

If Range("K" & compRow) = Range("K" & rowNo) Then

If Range("L" & compRow) = Range("L" & rowNo) Then

Range("J" & compRow & ":L" & compRow).Interior.Color = vbYellow
Range("J" & rowNo & ":L" & rowNo).Interior.Color = vbYellow
End If
End If
End If
Next compRow
Next rowNo
End Sub
Any ideas?

Fluff

MrExcel MVP, Moderator
You are missing the procedure name, normally like
Code:
``Sub Macro1()``

Fluff

MrExcel MVP, Moderator

If you just want to highlight duplicate rows try﻿
Rich (BB code):
``````Sub ghrek()
Dim Cl As Range
Dim Vlu As String

With CreateObject("scripting.dictionary")
For Each Cl In Range("J2", Range("J" & Rows.Count).End(xlUp))
Vlu = Cl.Value & "|" & Cl.Offset(, 1).Value & "|" & Cl.Offset(, 2).Value
If Not .Exists(Vlu) Then
Else
Cl.Resize(, 3).Interior.Color = VbYellow
.Item(Vlu).Resize(, 3).Interior.Color = VbYellow
End If
Next Cl
End With
End Sub``````

Last edited:

ghrek

Active Member
I tried that and it does columns J.K.L but I need column M too.

I amended macro to this but it dont seem to change any ideas?

Sub ghrek()
Dim Cl As Range
Dim Vlu As String

With CreateObject("scripting.dictionary")
For Each Cl In Range("J2", Range("J" & Rows.Count).End(xlUp))
Vlu = Cl.Value & "|" & Cl.Offset(, 1).Value & "|" & Cl.Offset(, 2).Value & "|" & Cl.Offset(, 3).Value
If Not .Exists(Vlu) Then
Else
Cl.Resize(, 3).Interior.Color = vbYellow
.Item(Vlu).Resize(, 3).Interior.Color = vbYellow
End If
Next Cl
End With
End Sub

Last edited:

ghrek

Active Member
It OK played around and sorted. Thanks for original coded fluff. As always a great help.

Fluff

MrExcel MVP, Moderator
Glad to help & thanks for the feedback

Replies
2
Views
243
Replies
2
Views
596
Replies
6
Views
275
Replies
7
Views
441
Replies
3
Views
261

1,141,488
Messages
5,706,665
Members
421,460
Latest member
MTME

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.

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

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