change font color to match interior color of another cell

kevin lazell

Well-known Member
Joined
Jun 2, 2004
Messages
513
hi guys
is it possible to click on say cell a1 that is empty but filled red and then click on say cell a2 which holds the value 12 and have the 12 turn red. in other words click on cell a1 get the interior colorindex =3 then click on a2 and have the font in a2 turn red if so how do i go about it please.
cheers kev
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can do it with double-clicks; this in the sheet's code module (right click the tab and choose View Code, then paste this in (I used 4 different colours in cells A1:A4 instead of just a single cell) Double click on one of the filled cells, then double click on the cell whose text colour you want changing;
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Static NextDoubleClickDoesSomething
Static Couleur
If Intersect(Target, Range("A1:A4")) Is Nothing Then
  If NextDoubleClickDoesSomething Then
    Target.Font.Color = Couleur
    NextDoubleClickDoesSomething = False
  End If
Else
  NextDoubleClickDoesSomething = True
  Couleur = Target.Interior.Color
End If
End Sub
 
Upvote 0
hi p45cal
thankyou very much for your code it works a treat, are you saying it can't be done with a single click?
 
Upvote 0
If anyone says it can't be done… someone will prove them wrong. However it'll be considerably more difficult to do it with single clicks. Would you want that? Single clicking is the commonest way of navigating around a sheet.
 
Upvote 0
hi p45cal
i think i would have prefered it but its not essential, your code works very well and i am happy with that thank you once again.
cheers kev
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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