Assign a value to a colored cell

neholsti

New Member
Joined
Mar 10, 2011
Messages
10
what I’m trying to do is a little out of my league. I have a spreadsheet with a whole bunch of cells with different colors (blue, green, yellow, and red) and these colors show at what stage a project is in. I wanted to make a macro that would assign each color a number (blue = 5, green = 4, yellow = 3, and red = 1) for computing the progress of each project. I really have no idea where to start, I know that you need to relate the value with the color index number, but that’s about it. If you have time and can help me I greatly appreciate it
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try this. It will do the first 6 Excel colours, you can add to it or alter it to suit the colours you are using.
Code:
Option Explicit
Sub NumberColurValue()
    Dim R As Range
    With ActiveSheet
        For Each R In ActiveSheet.UsedRange
            Select Case R.Interior.ColorIndex
                Case 1
                R.Interior.ColorIndex = 1
                R.Value = 1
                Case 2
                R.Interior.ColorIndex = 2
                R.Value = 2
                Case 3
                R.Interior.ColorIndex = 3
                R.Value = 3
                Case 4
                R.Interior.ColorIndex = 4
                R.Value = 4
                Case 5
                R.Interior.ColorIndex = 5
                R.Value = 5
                Case 6
                R.Interior.ColorIndex = 6
                R.Value = 6
            End Select
        Next R
 End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,258
Members
452,901
Latest member
LisaGo

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