Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default change background color of row until condition is met

I have 2 columns, status and order. If the status is "T", then the whole
row for that work order should have a yellow background. next time the
order is entered and its status is still "T", that row should be yellow
too until the status for the order becomes "C"
when it bcomes "C", all the yellow rows should be back to default

A B
ORDER STATUS
1 T
2 C
1 T
1 C

So the first and third rows should be yellow, but when i enter the
fourth row and enter "C" for status, all rows associated with order 1
should be back to default, ie no background color.

Thanks


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default change background color of row until condition is met

Hi
see your answers in Excel.misc.

Frank
P.S.: please don't multipost as this scatters your answers


I have 2 columns, status and order. If the status is "T", then the
whole row for that work order should have a yellow background. next
time the order is entered and its status is still "T", that row
should be yellow too until the status for the order becomes "C"
when it bcomes "C", all the yellow rows should be back to default

A B
ORDER STATUS
1 T
2 C
1 T
1 C

So the first and third rows should be yellow, but when i enter the
fourth row and enter "C" for status, all rows associated with order 1
should be back to default, ie no background color.

Thanks


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default change background color of row until condition is met

I think this should do it:

Sub test()
Dim i As Long, j As Long, lngLastRow As Long, lngColour As Variant

With Sheet1
lngLastRow = .Cells(Rows.Count, 1).End(xlUp).Row

For i = lngLastRow To 2 Step -1
Select Case .Cells(i, 2).Value
Case "T": lngColour = 6
Case "C": lngColour = xlColorIndexNone
End Select
For j = i + 1 To lngLastRow
If .Cells(i, 1).Value = .Cells(j, 1).Value Then
lngColour = .Rows(j).Interior.ColorIndex
Exit For
End If
Next
.Rows(i).Interior.ColorIndex = lngColour
Next
End With
End Sub



--
Rob van Gelder - http://www.vangelder.co.nz/excel


"fullymooned " wrote in message
...
I have 2 columns, status and order. If the status is "T", then the whole
row for that work order should have a yellow background. next time the
order is entered and its status is still "T", that row should be yellow
too until the status for the order becomes "C"
when it bcomes "C", all the yellow rows should be back to default

A B
ORDER STATUS
1 T
2 C
1 T
1 C

So the first and third rows should be yellow, but when i enter the
fourth row and enter "C" for status, all rows associated with order 1
should be back to default, ie no background color.

Thanks


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checkbox to change background color, font color and remove/ add bo Sara Excel Discussion (Misc queries) 2 May 1st 23 11:43 AM
count if font and background color condition is true Ivano Excel Worksheet Functions 3 February 28th 08 06:08 AM
how can I conditionally change font color, or background color? MOHA Excel Worksheet Functions 3 August 21st 06 06:57 PM
change background row color with change of date in a cell Urszula Excel Discussion (Misc queries) 5 May 17th 06 07:56 AM
Change of text or background color doesn't change on the screen. Susan Excel Discussion (Misc queries) 5 July 29th 05 07:18 PM


All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"