Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i change cell text colour based on value in other cell | Excel Worksheet Functions | |||
Change selected cell shading colour | Excel Discussion (Misc queries) | |||
Default value for selected cell colour change Excel 2007 | Setting up and Configuration of Excel | |||
How to change cell text based on another selected cell? | Excel Discussion (Misc queries) | |||
how do i get cell to change colour when text is added to it to hi. | Excel Discussion (Misc queries) |