code that changes font color of column A and Row 1 upon selection

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hey excel gurus,

I want to know how to change the font in column A and Row 1 of the selected column and selected row respectively.

The following is a code that would highlight the entire selected column and row,

Code:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
'Update 20140318
Static xRow
Static xColumn
If xColumn <> "" Then
    With Columns(xColumn).Interior
        .ColorIndex = xlNone
    End With
    With Rows(xRow).Interior
        .ColorIndex = xlNone
    End With
End If
pRow = Selection.Row
pColumn = Selection.Column
xRow = pRow
xColumn = pColumn
With Columns(pColumn).Interior
    .ColorIndex = 20
    .Pattern = xlSolid
End With
With Rows(pRow).Interior
    .ColorIndex = 22
    .Pattern = xlSolid
End With
End Sub


instead the column A and row 1 font's color are required to be changed into green, and back to black when selection moves away.

Thank you for any help.
will appreciate a lot.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
See if this does what you want.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveSheet.Cells.Interior.ColorIndex = xlNone
    With Cells(Selection.Row, 1).Interior
        .ColorIndex = 22
        .Pattern = xlSolid
    End With
    With Cells(1, Selection.Column).Interior
        .ColorIndex = 20
        .Pattern = xlSolid
    End With
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,184
Members
452,615
Latest member
bogeys2birdies

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