VBA code to change color of text based on location of active cell?

EssKayKay

Active Member
Joined
Jan 5, 2003
Messages
407
Office Version
  1. 2007
Platform
  1. Windows
Hello,

I have a question related to previous posting if you please.

I am looking for way to change the color of the text in a cell in column C based on the cell that is active in column I for the corresponding row. That is, if cell I44 is the active cell, then the text in cell C44 changes to red.

I have coding I received elsewhere that does this for a different column relationship (I apologize to the author as I don’t exactly remember who gave this to me). As example, in my current code, if the active cell is M55 then the text in C55 changes to red. I’d like a similar thing to happen if the active cell is in column I.

Here is my existing code. Please note, the proposed code does not have to be the same as the current. I simply posted it as an example. If you have a different idea that’s fine –

VBA Code:
Option Explicit
Public Old As Integer
Public Now As Integer

‘- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    If Not Intersect(target, Range("M32:M2032")) Is Nothing Then
      Now = (Split(ActiveCell(1).Address(1, 0), "$")(1))
          If (Old <> Now) Then
             UnProtect_It
             Range(Cells(Now, 3), Cells(Now, 3)).Font.Color = vbRed
             If Old Then Range(Cells(Old, 3), Cells(Old, 3)).Font.Color = False
             Range(Cells(Now, 3), Cells(Now, 3)).Font.Bold = True
             If Old Then Range(Cells(Old, 3), Cells(Old, 3)).Font.Bold = False
             Protect_It
          End If
       Old = Now
    End If

Thanks for viewing,
Steve K.
 
Thank you all very much for your input. With a little adjustment I have this working perfectly.

Again, my sincere appreciation,
Steve
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
OOPS - I may have spoken too soon (could not edit). I ran into a few more issues. I'll keep working on it and be back with my results.
Keeping my fingers crossed. . .
 
Upvote 0
Got it. I had to rearrange some coding in my Worksheet_SelectionChange sub. Seems to be doing what I want now.
As noted, you all are most certainly appreciated. . .
 
Upvote 0
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Forum statistics

Threads
1,223,711
Messages
6,174,025
Members
452,542
Latest member
Bricklin

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