Help with vba

jbklee66

New Member
Joined
Sep 13, 2006
Messages
6
Can someone help with code to change font colour of a range when a cell in the range is clicked

Ta
 
If you put it in the Worksheet_SelectionChange event under the Sheet module instead of the ThisWorkbook module, it will limit it to just that sheet.

Here is a link on all the different Event Procedures:
http://www.cpearson.com/excel/events.htm

The code may then look like this:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Static OldRange As Range
On Error Resume Next
Target.EntireRow.Interior.ColorIndex = 6 ' yellow - change as needed
OldRange.EntireRow.Interior.ColorIndex = xlColorIndexNone
Set OldRange = Target

End Sub
As for code to turn it back to black, it should already do that automatically. It only changes the color of the Active Row. Once you go to a different row, it should automatically change the old row back to what it was.
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,214,835
Messages
6,121,880
Members
449,057
Latest member
Moo4247

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