Shading Selected Cells

mattyn

Board Regular
Joined
Apr 20, 2015
Messages
148
Good Day All

New to the forum, but relatively competenent with the basics of Excel. I will be asking a lot of questions as I try to expand my knowledge, so i thank you all in advance.

First one: A worksheet that acts as a personnel management whereabouts tool. I want to be able to selct a few cells, and then click a button with an associated macro so that those selected cells are then shaded a particular colour.

For instance, I select A15:G15 with the mouse, then click a button to shade it green.

Hope this makes sense? Is it possible?

Cheers

Matt
 
I have tried Selection.Interior.Color=xlNone but it turns the selected cells blue!

Any thoughts? I don't want to use white as I want it transparent!
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Where I have sorted the shading above, how would I add a letter to each cell that was shaded?

I would like to add for instance:

Red cells - L
Blue cells - D
etc?
 
Upvote 0
Where I have sorted the shading above, how would I add a letter to each cell that was shaded?

I would like to add for instance:

Red cells - L
Blue cells - D
etc?

You could try this.

Change the 3 for the color from your colorindex code you have and the L to the letter you want.

I assigned the short cut key Ctrl + q to my example for ease of use.
Each user could have a separate short cut key code, where the user would select the cells and hit Ctrl + ?.
You would need to be careful not to use the Reserved Short Cuts that Excel uses, but there are a fair amount available.
Then you enter the short cut below the name for a reminder like '/ Ctrl + q


Howard

Code:
Sub Cell_Col_Letter()
'/ Ctrl + q

Dim rngC As Range

For Each rngC In Selection
    rngC.Interior.ColorIndex = IIf(rngC.Interior.ColorIndex = xlNone, _
        3, xlNone)
    rngC = IIf(rngC = "", "L", "")
Next

End Sub
 
Upvote 0
You could try this.

Change the 3 for the color from your colorindex code you have and the L to the letter you want.

I assigned the short cut key Ctrl + q to my example for ease of use.
Each user could have a separate short cut key code, where the user would select the cells and hit Ctrl + ?.
You would need to be careful not to use the Reserved Short Cuts that Excel uses, but there are a fair amount available.
Then you enter the short cut below the name for a reminder like '/ Ctrl + q


Howard

Code:
Sub Cell_Col_Letter()
'/ Ctrl + q

Dim rngC As Range

For Each rngC In Selection
    rngC.Interior.ColorIndex = IIf(rngC.Interior.ColorIndex = xlNone, _
        3, xlNone)
    rngC = IIf(rngC = "", "L", "")
Next

End Sub

Thank you. I assume I use that instead of the code I use currently on each macro?
 
Upvote 0
Thank you. I assume I use that instead of the code I use currently on each macro?

Assume you have three users.

I would disregard the use of short cut keys, can be troublesome if mixed with Excel Reserved Short Cut Keys.

Instead assign each user to a small button, or even better, a small SHAPE formatted to the color and a text insert of the letter of the user.

Sub Cell_Col_L() user would have a shape filled red with an L in it.
Sub Cell_Col_M() user would have a shape filled green with an M in it.
Sub Cell_Col_N() user would have a shape filled yellow with an N in it.



Code:
Option Explicit

Sub Cell_Col_L()
Dim rngC As Range
For Each rngC In Selection
    rngC.Interior.ColorIndex = IIf(rngC.Interior.ColorIndex = xlNone, _
        3, xlNone)
    rngC = IIf(rngC = "", "L", "")
Next
End Sub


Sub Cell_Col_M()
Dim rngC As Range
For Each rngC In Selection
    rngC.Interior.ColorIndex = IIf(rngC.Interior.ColorIndex = xlNone, _
        4, xlNone)
    rngC = IIf(rngC = "", "M", "")
Next
End Sub


Sub Cell_Col_N()
Dim rngC As Range
For Each rngC In Selection
    rngC.Interior.ColorIndex = IIf(rngC.Interior.ColorIndex = xlNone, _
        6, xlNone)
    rngC = IIf(rngC = "", "N", "")
Next
End Sub

Howard
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

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