ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Macro to change row and font color based on column value (https://www.excelbanter.com/excel-programming/338906-excel-macro-change-row-font-color-based-column-value.html)

MT[_2_]

Excel Macro to change row and font color based on column value
 
I have a worksheet which I need to change the font color and row color
for a portion of the cells in a row. For example I have data in the
first five columns of a row, the sixth column is the column which
influences the change (data is text), then I have data in columns seven
though ten which will need to be changed based on column six, finally
there is columns eleven through fourteen which are not effected by the
change. I have been able to get the entire row to change but I can not
get only the portions I want to change. Also column six is a list so
initially it is blank but when I select a value that is when the change
takes place. Thanks for your help.


Rowan[_4_]

Excel Macro to change row and font color based on column value
 
Maybe

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 And Target.Count = 1 Then
If Target.Value = "Criteria for change" Then
With Range(Cells(Target.Row, 7), Cells(Target.Row, 10))
.Font.ColorIndex = 2
.Interior.ColorIndex = 15
End With
End If
End If
End Sub

This is worksheet event code. Right click the sheet tab, select View Code
and paste the code in there.

Hope this helps
Rowan

"MT" wrote:

I have a worksheet which I need to change the font color and row color
for a portion of the cells in a row. For example I have data in the
first five columns of a row, the sixth column is the column which
influences the change (data is text), then I have data in columns seven
though ten which will need to be changed based on column six, finally
there is columns eleven through fourteen which are not effected by the
change. I have been able to get the entire row to change but I can not
get only the portions I want to change. Also column six is a list so
initially it is blank but when I select a value that is when the change
takes place. Thanks for your help.



Steve[_63_]

Excel Macro to change row and font color based on column value
 
place this in the worksheet change event (thisworkbook module)
this will test a change


Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Excel.Range)

if target.column= 10 then

If Target = "1" Then
For i = 1 To 3
Cells(Target.Row, Target.Column).Offset(0,
i).Interior.ColorIndex = 14
Next i
End If

If Target = "" Then
For i = 1 To 3
Cells(Target.Row, Target.Column).Offset(0,
i).Interior.ColorIndex = xlNone
Next i
End If

end if

End Sub

hth
steve


On 31 Aug 2005 21:22:41 -0700, "MT" wrote:

I have a worksheet which I need to change the font color and row color
for a portion of the cells in a row. For example I have data in the
first five columns of a row, the sixth column is the column which
influences the change (data is text), then I have data in columns seven
though ten which will need to be changed based on column six, finally
there is columns eleven through fourteen which are not effected by the
change. I have been able to get the entire row to change but I can not
get only the portions I want to change. Also column six is a list so
initially it is blank but when I select a value that is when the change
takes place. Thanks for your help.



MT[_2_]

Excel Macro to change row and font color based on column value
 
Thanks I will give this a try


MT[_2_]

Excel Macro to change row and font color based on column value
 
Thanks I will try both and let you guys know.



All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com