I have a macro that does a number of updates to my source data and finally sorts by column A and highlights duplicates in column A using this code ...
It runs perfectly from the VBA "console", but when I assign the macro to a control button, this final part of the code doesn't run (the previous code runs fine!) ...
Any ideas?
VBA Code:
'Sort by ID
Dim rg As Range: Set rg = Range("A2:A" & lRow)
rg.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlYes
'Highlight duplicate IDs
'clear any existing conditional formatting
rg.FormatConditions.Delete
'identify duplicate values in rg
Dim uv As UniqueValues: Set uv = rg.FormatConditions.AddUniqueValues
uv.DupeUnique = xlDuplicate
'apply conditional formatting to duplicate values
uv.Interior.Color = vbCyan
It runs perfectly from the VBA "console", but when I assign the macro to a control button, this final part of the code doesn't run (the previous code runs fine!) ...
Any ideas?