Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CB CB is offline
external usenet poster
 
Posts: 60
Default Fill Cells with Red

I have a spreadsheet that I need to fill the interior color of the row red if
column f contains the text red. I need the data in each row to turn red if f
is red for columns a through e and g through m.
Is there an easy way to do this other than sorting/filtering. I have
already used the conditional formatting option for another purpose. Is there
some
way to do this with VBA?

Any help is appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Fill Cells with Red

Sub cb()
n = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To n
If Cells(i, "F").Value = "red" Then
Range("A" & i & ":E" & i).Interior.ColorIndex = 3
Range("G" & i & ":M" & i).Interior.ColorIndex = 3
End If
Next
End Sub
--
Gary''s Student
gsnu200708


"CB" wrote:

I have a spreadsheet that I need to fill the interior color of the row red if
column f contains the text red. I need the data in each row to turn red if f
is red for columns a through e and g through m.
Is there an easy way to do this other than sorting/filtering. I have
already used the conditional formatting option for another purpose. Is there
some
way to do this with VBA?

Any help is appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
CB CB is offline
external usenet poster
 
Posts: 60
Default Fill Cells with Red

Thanks Gary. This is just what I needed.

"Gary''s Student" wrote:

Sub cb()
n = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To n
If Cells(i, "F").Value = "red" Then
Range("A" & i & ":E" & i).Interior.ColorIndex = 3
Range("G" & i & ":M" & i).Interior.ColorIndex = 3
End If
Next
End Sub
--
Gary''s Student
gsnu200708


"CB" wrote:

I have a spreadsheet that I need to fill the interior color of the row red if
column f contains the text red. I need the data in each row to turn red if f
is red for columns a through e and g through m.
Is there an easy way to do this other than sorting/filtering. I have
already used the conditional formatting option for another purpose. Is there
some
way to do this with VBA?

Any help is appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Fill Cells with Red

One way:

Put this in your worksheet code module:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rIntersect As Range
Dim rCell As Range
Dim nCI As Long
Set rIntersect = Intersect(Target, Columns("F"))
If Not rIntersect Is Nothing Then
For Each rCell In rIntersect
With rCell
If LCase(rCell.Text) = "red" Then
nCI = 3
Else
nCI = xlColorIndexNone
End If
Union(.Offset(0, -5).Resize(1, 5), _
.Offset(0, 1).Resize(1, 7)).Interior.ColorIndex = nCI
End With
Next rCell
End If
End Sub


In article ,
CB wrote:

I have a spreadsheet that I need to fill the interior color of the row red if
column f contains the text red. I need the data in each row to turn red if f
is red for columns a through e and g through m.
Is there an easy way to do this other than sorting/filtering. I have
already used the conditional formatting option for another purpose. Is there
some
way to do this with VBA?

Any help is appreciated.

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
Fill Cells Based On Cells In Another Sheet [email protected] Excel Worksheet Functions 1 May 31st 07 10:30 PM
Fill cells with color based on criteria in two cells AA Excel Worksheet Functions 2 January 2nd 06 11:29 PM
How do I fill (copy) nonadjacent cells to adjacent cells? BuckyGeorge Excel Discussion (Misc queries) 2 December 22nd 05 04:18 AM
create a fill in template to tab to fill in cells Excel-erator Excel Discussion (Misc queries) 2 July 6th 05 09:57 PM
HOW TO FORMATE CELLS TO COUNT CELLS WITH A FILL COLOR? Moore New Users to Excel 1 June 15th 05 06:41 PM


All times are GMT +1. The time now is 10:54 PM.

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

About Us

"It's about Microsoft Excel"