I am trying to create a program that finds duplicates in a large excel sheet.
However this sheet has gaps in the data for labeling purposes as the data is entered by month and by person. I need to find a way to highlight and count the number of duplicates.
I have got it to highlight duplicates in one range using
If Application.WorksheetFunction.CountIf(Range1, Cell) > 1 Then
but I need to get two or more ranges into the countif function. Basically I need to compare data for duplicates in a non-continuous range.
So I have the ranges
C4:H78 J4:O78 Q4:V78
How would I add those together in VBA, so all ranges are being compared to each other?
I have tried
If Application.WorksheetFunction.Sum(Application.WorksheetFunction.CountIf(Range1, Cell),Application.WorksheetFunction.CountIf(Range2, Cell),etc) > 1 Then
and using the Union(range1,range2)
to create one union of range but that didn't work.
I have summed countif in excel directly with =SUM(COUNTIF(INDIRECT({"Range1","RANGE2",etc}),criteria))
However INDIRECT
does not work in VBA that I can find.
I am new to VBA in excel. Thank you for any help you can give.
If ( _
Application.WorksheetFunction.CountIf(Range1, Cell) + _
Application.WOrksheetFunction.CountIf(Range2, Cell) + _
Application.WOrksheetFunction.CountIf(Range3, Cell) _
) > 1 Then
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.