ka_inc
asked on
Run-time error with VBA code in Excel 2010
Have the typical code to highlight duplicate cells with custom formatting: [$-409]m/d/yyyy h:mm:ss AM/PM;@
For Each cel In myrng
If Application.WorksheetFunct ion.CountI f(myrng, cel) > 1 Then
If WorksheetFunction.CountIf( Range("H2: H" & cel.Row), cel) = 1 Then
cel.Interior.ColorIndex = clr
Else
cel.Interior.ColorIndex = myrng.Cells(WorksheetFunct ion.Match( cel.Value, myrng, False), 1).Interior.ColorIndex
End If
End If
Next
The code will highlight the original cell but will throw the Run-time error 1004 "Unable to get the Match property of Worksheetfunction class" on the duplicate cell.
Why is it doing this and how to fix.
Thank you
For Each cel In myrng
If Application.WorksheetFunct
If WorksheetFunction.CountIf(
cel.Interior.ColorIndex = clr
Else
cel.Interior.ColorIndex = myrng.Cells(WorksheetFunct
End If
End If
Next
The code will highlight the original cell but will throw the Run-time error 1004 "Unable to get the Match property of Worksheetfunction class" on the duplicate cell.
Why is it doing this and how to fix.
Thank you
It works for me without any problem..Can you post your sample file to look over to see whats wrong..
ASKER
This is the sample file.
Thank you
Thank you
ASKER
In your code you have declaration this..
change this to
This will take care of this error..
Saurabh...
dim cel as variant
change this to
Dim cel As Range
This will take care of this error..
Saurabh...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you