jbesclapez
Active Member
- Joined
- Feb 6, 2010
- Messages
- 275
Dear Mr and Mme Excel,
I have a script that I did (or took) a year ago but it is running super slow and I end up killing Excel (none of your family member Mr Excel!)
I have 2 sheets that should be idential with columns A to G. My Script is devided into 2 tasks. The first one orders the data and the second compairs.
Script 1 :
I add a column in A that concatenates B:G and then i sort by alphabetical order. So I sort on column A. Each line is unique.
Script 2:
That is the slow one. The one I need help.
I want it to compair A and B and to show what exist in A and not in B but also what exist in B and not in A. All this should show in sheet3:
Can you find a way to make this a lot faster? As I was saying, if you compare only the first column it should be fine....
Thanks !
I have a script that I did (or took) a year ago but it is running super slow and I end up killing Excel (none of your family member Mr Excel!)
I have 2 sheets that should be idential with columns A to G. My Script is devided into 2 tasks. The first one orders the data and the second compairs.
Script 1 :
I add a column in A that concatenates B:G and then i sort by alphabetical order. So I sort on column A. Each line is unique.
Script 2:
That is the slow one. The one I need help.
I want it to compair A and B and to show what exist in A and not in B but also what exist in B and not in A. All this should show in sheet3:
VBA Code:
Dim rngCell As Range
For Each rngCell In sht1.Range("A2:A" & LastRowAsht1)
If WorksheetFunction.CountIf(sht2.Range("A2:A" & LastRowAsht2), rngCell) = 0 Then
sht3.Range("A" & Rows.Count).End(xlUp).Offset(1) = rngCell
End If
Next
For Each rngCell In sht2.Range("A2:A" & LastRowAsht2)
If WorksheetFunction.CountIf(sht1.Range("A2:A" & LastRowAsht1), rngCell) = 0 Then
sht3.Range("B" & Rows.Count).End(xlUp).Offset(1) = rngCell
End If
Next
Can you find a way to make this a lot faster? As I was saying, if you compare only the first column it should be fine....
Thanks !