Can I improve a worboook to work more efficently

ghrek

Active Member
Joined
Jul 29, 2005
Messages
301
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

Thanks in advance.
 

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
Joined
Jun 27, 2011
Messages
2,006
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
Joined
Jul 29, 2005
Messages
301
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
Joined
Jun 27, 2011
Messages
2,006
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
Joined
Jul 29, 2005
Messages
301

ADVERTISEMENT

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
Joined
Jun 12, 2014
Messages
62,473
Office Version
  1. 365
Platform
  1. Windows
You are missing the procedure name, normally like
Code:
Sub Macro1()
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,473
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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
            .Add Vlu, Cl
         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
Joined
Jul 29, 2005
Messages
301
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
.Add Vlu, Cl
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
Joined
Jul 29, 2005
Messages
301
It OK played around and sorted. Thanks for original coded fluff. As always a great help.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,473
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback
 

Forum statistics

Threads
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.
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
Top