cell color change with a button click

800kay

New Member
Joined
Apr 18, 2019
Messages
2
My intention is to color fill a specific cell (e.g. A1) with a click of a button (Button1) I've created.
Another click of a button would un-fill the color.

Another question that is not a priority is to open a "new comment" box for a specific cell for user to start entering in their comment with a click of a button (Button2)

Can anyone help out with this macro?

Thanks!!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
First question
-------------------------------------
Assign this Sub to the button (3 is the ColorIndex number for red, change as needed)...
Code:
Sub ColorToggleCellA1()
  Range("A1").Interior.ColorIndex = xlColorIndexNone + 3 - Range("A1").Interior.ColorIndex
End Sub

Second question
-------------------------------------
I don't think it is possible to do that directly as I think editing a Comment would put Excel into Edit Mode and macros cannot run when Excel is in Edit Mode. You might use a TextBox as an intermediary and assign its contents to the cell's Comment.
 
Last edited:
Upvote 0
Amazing.... :)

If it's not so much to ask, is it possible to use RGB colors instead of ColorIndex as colorindex has limited colors to choose from. and how would I also add so that it the color fill/un-fill would apply to the actually button as well?


Thank you so much you're already a lifesaver!!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,185
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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