ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change text colour of a cell when a different cell is selected (https://www.excelbanter.com/excel-programming/367363-change-text-colour-cell-when-different-cell-selected.html)

[email protected]

Change text colour of a cell when a different cell is selected
 
This problem is likely to be very easy for anyone with basic macro
knwoledge.

I need to know how to automatically change the colour of the text in
cell B4 to red everytime cell A4 is selected, then back to black when
cell A4 is unselected. Also, where do I place the code to perform this?

Any help will be much appreciated.


excelent

Change text colour of a cell when a different cell is selected
 
try put in sheet-tab kode-window


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveCell.Row = 4 And ActiveCell.Column = 1 Then
Cells(4, 2).Font.ColorIndex = 3
Else
Cells(4, 2).Font.ColorIndex = 1
End If
End Sub



" skrev:

This problem is likely to be very easy for anyone with basic macro
knwoledge.

I need to know how to automatically change the colour of the text in
cell B4 to red everytime cell A4 is selected, then back to black when
cell A4 is unselected. Also, where do I place the code to perform this?

Any help will be much appreciated.



Stefi

Change text colour of a cell when a different cell is selected
 
1. Invoke VBE (Alt+F11)!
2. Right click on your project name in project window, choose Insert/Module
from the local menu!
3. Copy this function into window Module 1!
Function IsSelected(cellref)
IsSelected = ActiveCell.Address(False, False) = cellref
End Function
4. Right click on your sheet name (say Sheet1) in project window, choose
View code!
5 Insert this event macro into window Sheet1
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Calculate
End Sub
6. Go back to Sheet1, select cell B4!
7. Formats/Conditional formatting, choose formula as condition and enter
=isselected("A4") into the formula field, press Format button and select Font
tag, apply red color, then OK/OK!

Regards,
Stefi

ezt *rta:

This problem is likely to be very easy for anyone with basic macro
knwoledge.

I need to know how to automatically change the colour of the text in
cell B4 to red everytime cell A4 is selected, then back to black when
cell A4 is unselected. Also, where do I place the code to perform this?

Any help will be much appreciated.



ChristianH[_2_]

Change text colour of a cell when a different cell is selected
 
The following will change the font color of cell B4 when active

If ActiveCell = Cells(4, 1) Then
Cells(4, 2).Font.ColorIndex = 3
Else
Cells(4, 2).Font.ColorIndex = 1
End If

Paste it into your Worksheet_SelectionChange(ByVal Target As Range)
event.

Christian

wrote:

This problem is likely to be very easy for anyone with basic macro
knwoledge.

I need to know how to automatically change the colour of the text in
cell B4 to red everytime cell A4 is selected, then back to black when
cell A4 is unselected. Also, where do I place the code to perform this?

Any help will be much appreciated.




All times are GMT +1. The time now is 12:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com