Highlight Cells in Active Row

  • Thread starter Thread starter Pete
  • Start date Start date
P

Pete

Hi,

Can anyone tell me how to highlight cells in column A & B of the
active row, I wish this to be a Workbook command if possible.

Thanks

Peter
 
Pete said:
Hi,

Can anyone tell me how to highlight cells in column A & B of the
active row, I wish this to be a Workbook command if possible.


I used the macro recorder to get trhis:

Range("A4:B4").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With

I'd suggest that you use the macro recorder to discover what values give
you the highlight you want.

Then, I'd replace

Range("A4:B4").Select
With Selection.Interior

with

With ActiveCell.EntireRow.Columns("A:B").Interior

to highlight columns A and B of the active row.
 
Right click sheet tab>view code>paste this. Now when you select a row
it will highlight col a & b of that row

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
'With Target.EntireRow
With Cells(Target.Row, 1).Resize(, 2)
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 6 '35
End With
End Sub
 
Right click sheet tab>view code>paste this. Now when you select a row
it will highlight col a & b of that row

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Cells.FormatConditions.Delete
           'With Target.EntireRow
    With Cells(Target.Row, 1).Resize(, 2)
      .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
      .FormatConditions(1).Interior.ColorIndex = 6      '35
    End With
End Sub




- Show quoted text -

Can this be adapted to work with the Workbook_SelectionChange Sub?

Thanks in advance

Peter
 
Can this be adapted to work with the Workbook_SelectionChange Sub?

Thanks in advance

Peter- Hide quoted text -

- Show quoted text -


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
Cells.FormatConditions.Delete
'With Target.EntireRow
With Cells(Target.Row, 1).Resize(, 2)
.FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
.FormatConditions(1).Interior.ColorIndex = 6 '35
End With

End Sub
 
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)
  Cells.FormatConditions.Delete
           'With Target.EntireRow
    With Cells(Target.Row, 1).Resize(, 2)
      .FormatConditions.Add Type:=xlExpression, Formula1:="TRUE"
      .FormatConditions(1).Interior.ColorIndex = 6      '35
    End With

End Sub- Hide quoted text -

- Show quoted text -

Don, this is what I want, which is to highlight Column A & B of the
Active Row however I already have conditional formatting applied with
Condition 1 & 2, could you amend so that this Sub allows me to retain
what I have and still highlight column A & B as you have done?

Thanks in advance,
 
Back
Top