VBA - Sort Duplicate Value based on Cell Colour

ash27

New Member
Joined
Jun 30, 2021
Messages
2
Office Version
  1. 365
Platform
  1. MacOS
Hi there,

Been using a VBA to sort duplicates within an Active Sheet that have been marked with the default 'highlight duplicate' cell colour (RGB 255, 199, 206).

All of a sudden my VBA is not working.... (red font is code being highlighted to debug).

Here is the code:


Sub SortDups2()
'
' SortDups2 Macro
'

'
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add(Range("I2"), _
xlSortOnCellColor, xlAscending, , xlSortNormal).SortOnValue _
.Color = RGB(255, 199, 206)

With ActiveSheet.Sort
.SetRange Range("A1").CurrentRegion
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub


Any reasons why all of a sudden it wouldn't be working?

Cheers
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
No error seen on my end, did you try rebooting computer and see if it works?

If you get error after reboot, what is the error that it displays?
 
Upvote 0
Solution
No error seen on my end, did you try rebooting computer and see if it works?

If you get error after reboot, what is the error that it displays?
Thanks JohnnyL!

The reboot seems to have done the trick!

I spent ages trying to work out what was wrong...

Appreciate the advice.

Cheers,
Ash
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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