Get a list of colours from a range of cells

PUGresources

New Member
Joined
Aug 6, 2019
Messages
7
I've got a range of cells that all have different interior colours (say the range is A1:AD30) Ideally i'd like some vba code that will look through the defined range and then work out what colours are in that range and then make almost a list of them visually at the side.

For example - say my range has red, blue, green, light orange, dark grey, light grey. i'd like the vba to put red as the interior colour in Cell AL1, then blue in AL2, then green in AL3 etc. Is this possible?

Any help would be appreciated please :)
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
How about
VBA Code:
Sub PUGresources()
   Dim Cl As Range
   Dim i As Long
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Range("A1:AD30")
         .Item(Cl.Interior.Color) = Empty
      Next Cl
      For i = 0 To .count - 1
         Range("AL" & i + 1).Value = .Keys()(i)
         Range("AL" & i + 1).Interior.Color = .Keys()(i)
      Next i
   End With
End Sub
 
Upvote 0
WOW That's literally amazing! Thank you.

I've been searching for something like this for SO long! I honestly can't believe the code for it is that short!

Thanks so much Fluff.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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