Can I improve a worboook to work more efficently

ghrek

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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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?
 
Upvote 0
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:
Upvote 0
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.
 
Upvote 0
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?
 
Upvote 0
You are missing the procedure name, normally like
Code:
Sub Macro1()
 
Upvote 0
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:
Upvote 0
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:
Upvote 0
It OK played around and sorted. Thanks for original coded fluff. As always a great help.
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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