combining 2 simple subroutines into 1 for changing cell color...

sadams1

Board Regular
Joined
Aug 19, 2006
Messages
219
hello & thank you for considering this! The following code changes the cell color to either yellow or no color & are hooked up to individual keyboard shortcuts.
I've been messing with combining them into 1 keyboard shortcut so it will prompt "what color...yellow or no color?" & then update the cell.
I'm posting this as I'm a hack at best but occasionally get lucky & something will work however this seems more involved than I'm thinking it is?



Sub cmtFillYellow()

Selection.Interior.Color = 65535

End Sub



Sub cmtFillNone()

Selection.Interior.Color = xlColorIndexNone

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Hello @sadams1

So, you want a question to come up and ask for the color. If so, then look into:
INPUTBOX. Here is an example:

==================================================================
Dim strColor as String

strColor= InputBox("What color do you want to color the cell?", "'Y' for yellow, 'Space" for No Color", "Enter your choice text HERE")
If UCASE(strColor) = "Y" then
cmtFillYellow
Else
cmtFillNone
End If
==================================================================
PS/N.B.: You can also test if the User pressed the Cancel button. There is plenty of code online to look at.

If you want to run the two subroutines from a single shortcut key that is impossible, and not advised, as is. Ask yourself how will the "system" know when to run "cmtFillYellow" and when it will run "cmtFillNone"?
You tell me to do something, I do it, but you can't tell me to guess what you want me to do??? I hope this is simple to understand.

If you want to run BOTH from the SAME shortcut key then look into:
CALL function.

Hope this helps.

If you need more help, let us know.

Montey
 
Upvote 0
hello Montey,
Thank you very much for your time...I'll mess with your code & see what trouble I can get into!

Quick question, would it be more efficient to design a simple color palette that can be brought up with the keyboard shortcut? For instance, code is designed to pop up a palette with only yellow, & "no fill" color swatches? I went down that rabbit hole & quickly found myself way over my head!
 
Upvote 0

Forum statistics

Threads
1,215,460
Messages
6,124,949
Members
449,198
Latest member
MhammadishaqKhan

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