ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   changing row color (https://www.excelbanter.com/excel-programming/344895-changing-row-color.html)

converting 05445 to 2005-10-04

changing row color
 
Hi,
I would like to change the row color according to an if statement.

if column A is bigger than column B than change the row color to blue
otherwise no change should occur. (i.e. if A1B1, A2B2, A3B3)

The change is on pre-existing data.

thank you,

Sten Melin

Bob Phillips[_6_]

changing row color
 
Select all of the rows, starting from 1

FormatConditional Formatting

Change Condition 1 to Formula Is
Add a Formula of =$A1$B1
Click format
Select Pattern
Choose a colour
OK out

--

HTH

RP
(remove nothere from the email address if mailing direct)


"converting 05445 to 2005-10-04"
om wrote in message
...
Hi,
I would like to change the row color according to an if statement.

if column A is bigger than column B than change the row color to blue
otherwise no change should occur. (i.e. if A1B1, A2B2, A3B3)

The change is on pre-existing data.

thank you,

Sten Melin




converting 05445 to 2005-10-04

changing row color
 
Thanks for your help and time Bob!

I did not quite express myself clearly.

I got a user that will paste information into an excel sheet.(sheet 1)

i have alreday recorded a macro (probably need to record a new one)
that copies the format from sheet 2 and paste it onto sheet one.
Sheet 2 is already row conditional formated to row 1000.

This works but its a bit slow.

So i was wondering to use something like this (see below).

But as im a newbie to programing i dont know how to change the "Select Case
LCase(Target.Value)" to an if statement and that the change macro should only
be applied up to and incl. the last row.

thank you,

Sten


---------------------------------------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'David McRitchie, 2004-09-26, programming, Case -- Entire Row
' http://www.mvps.org/dmcritchie/excel/event.htm#case
If Target.Column < 6 Then Exit Sub 'Column F is column 6
If Target.Row = 1 Then Exit Sub
Application.EnableEvents = False 'should be part of Change macro
Select Case LCase(Target.Value)
Case "yes"
Target.EntireRow.Interior.ColorIndex = 34
Case "no"
Target.EntireRow.Interior.ColorIndex = 36
Case Else
Target.EntireRow.Interior.ColorIndex = xlColorIndexAutomatic
End Select
Application.EnableEvents = True 'should be part of Change macro
End Sub
----------------------------------------------------------------------------------------------



"Bob Phillips" skrev:

Select all of the rows, starting from 1

FormatConditional Formatting

Change Condition 1 to Formula Is
Add a Formula of =$A1$B1
Click format
Select Pattern
Choose a colour
OK out

--

HTH

RP
(remove nothere from the email address if mailing direct)


"converting 05445 to 2005-10-04"
om wrote in message
...
Hi,
I would like to change the row color according to an if statement.

if column A is bigger than column B than change the row color to blue
otherwise no change should occur. (i.e. if A1B1, A2B2, A3B3)

The change is on pre-existing data.

thank you,

Sten Melin






All times are GMT +1. The time now is 03:01 AM.

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