Question: I'm looking for VBA code that will change the background color of a cell when I click on another cell. For example, if I click on cell A1, I'd like the background color of cell B2 to change to red. Answer: To change the background color of a cell A1 when cell B2 is clicked, we need to create a macro that is called when the Worksheet's SelectionChange event is fired. Download Excel spreadsheet (as demonstrated below) In the spreadsheet below, we've created a macro that will run each time the user selects a different cell on Sheet1.
|
If the user selects cell A1, the macro will set the background color of cell B2 to red.
|
You can view the macro by pressing Alt-F11. Macro Code:The macro code looks like this:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc