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

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
1,840
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.
 

Some videos you may like

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

mumps

Well-known Member
Joined
Apr 11, 2012
Messages
9,589
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:

Watch MrExcel Video

Forum statistics

Threads
1,109,368
Messages
5,528,274
Members
409,813
Latest member
robyrux

This Week's Hot Topics

  • Change military grades into rank
    Afternoon all Need help with formula that will change military rank (i.e. 1, 2, 3 into Amn, A1C, SrA). Running IF formula that does not work...
  • VBA COUNTIF SOLUTION
    Hi The following are the errors spread across the several columns from E to Q ie. 13 columns across several sheets with more than 500 rows per...
  • INSERT ROW WITH SPECIFIS TEXT IN A COLUMN
    Hi All! How can identify that that the row to be inserted has to be inserted before 1st row with specific text in column F. If I record the...
  • Auto-Create a monthly Sign in sheet for preschool students
    The image below is what each page looks like. Above is space for the "Child Name" "Month" "Class" School days are obviously Monday-Friday but...
  • VBA vlookup multiple results
    Hi folks, Hopefully someone out there can help. I have a list to vlookup which works (ish). the lookup only picks up the first instance of the...
  • Extract values for earliest/latest times
    I am trying to put together a formula to get the earliest start time, the latest end time from column A for each person in Column B-F without the...
Top