Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Add text in a cell based on colour of text in another cell

Hi

I have recorded a macro to add "For Sale" into cell J3 if the text in column
A3 is red. I added an IF THEN and it works but how do I get it to repeat in
all cells as in cell J4 needs to be set to "For Sale" if the text in cell A4
is red all the way down to J1311.

Sub Macro4()

Range("A3").Select
If Selection.Font.ColorIndex = 3 Then
Range("J3").Select
ActiveCell.FormulaR1C1 = "For Sale"

End If
End Sub

Thanks in advance

Ian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default Add text in a cell based on colour of text in another cell

Dim CRng As Range
Set CRng = Range("J3:J1311")
For Each cl In CRng.Cells
If cl.Offset(0, -9).Font.ColorIndex = 3 Then
cl.Value = "For Sale"
End If
Next cl

Hope this Helps

Duncan


Ian Richardson ACITP wrote:

Hi

I have recorded a macro to add "For Sale" into cell J3 if the text in column
A3 is red. I added an IF THEN and it works but how do I get it to repeat in
all cells as in cell J4 needs to be set to "For Sale" if the text in cell A4
is red all the way down to J1311.

Sub Macro4()

Range("A3").Select
If Selection.Font.ColorIndex = 3 Then
Range("J3").Select
ActiveCell.FormulaR1C1 = "For Sale"

End If
End Sub

Thanks in advance

Ian


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 290
Default Add text in a cell based on colour of text in another cell

Actually, if running this more than once and the cells in A3 are likely
to change, then reset the words if text not red? (just add an 'else')

Dim CRng As Range
Set CRng = Range("J3:J1311")
For Each cl In CRng.Cells
If cl.Offset(0, -9).Font.ColorIndex = 3 Then
cl.Value = "For Sale"
Else
cl.Value = ""
End If
Next cl

HTH

Duncan


Duncan wrote:

Dim CRng As Range
Set CRng = Range("J3:J1311")
For Each cl In CRng.Cells
If cl.Offset(0, -9).Font.ColorIndex = 3 Then
cl.Value = "For Sale"
End If
Next cl

Hope this Helps

Duncan


Ian Richardson ACITP wrote:

Hi

I have recorded a macro to add "For Sale" into cell J3 if the text in column
A3 is red. I added an IF THEN and it works but how do I get it to repeat in
all cells as in cell J4 needs to be set to "For Sale" if the text in cell A4
is red all the way down to J1311.

Sub Macro4()

Range("A3").Select
If Selection.Font.ColorIndex = 3 Then
Range("J3").Select
ActiveCell.FormulaR1C1 = "For Sale"

End If
End Sub

Thanks in advance

Ian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Add text in a cell based on colour of text in another cell

Hi Duncan

Thanks for the quick reply. Works like a dream!!

Ian

"Duncan" wrote:

Actually, if running this more than once and the cells in A3 are likely
to change, then reset the words if text not red? (just add an 'else')

Dim CRng As Range
Set CRng = Range("J3:J1311")
For Each cl In CRng.Cells
If cl.Offset(0, -9).Font.ColorIndex = 3 Then
cl.Value = "For Sale"
Else
cl.Value = ""
End If
Next cl

HTH

Duncan


Duncan wrote:

Dim CRng As Range
Set CRng = Range("J3:J1311")
For Each cl In CRng.Cells
If cl.Offset(0, -9).Font.ColorIndex = 3 Then
cl.Value = "For Sale"
End If
Next cl

Hope this Helps

Duncan


Ian Richardson ACITP wrote:

Hi

I have recorded a macro to add "For Sale" into cell J3 if the text in column
A3 is red. I added an IF THEN and it works but how do I get it to repeat in
all cells as in cell J4 needs to be set to "For Sale" if the text in cell A4
is red all the way down to J1311.

Sub Macro4()

Range("A3").Select
If Selection.Font.ColorIndex = 3 Then
Range("J3").Select
ActiveCell.FormulaR1C1 = "For Sale"

End If
End Sub

Thanks in advance

Ian



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
how do i change cell text colour based on value in other cell Oscarrot Excel Worksheet Functions 2 July 20th 09 03:21 PM
how to colour a cell green if another cell is filled with text terence Excel Discussion (Misc queries) 3 March 11th 07 04:38 PM
Cell Colour based on text in Range of cells viewmaster[_2_] Excel Programming 2 March 3rd 06 03:53 AM
Cell Colour based on text in Range of cells viewmaster Excel Programming 1 March 3rd 06 03:42 AM
Deleting Rows based on text in cell & formatting cell based on text in column beside it Steve Excel Programming 4 February 26th 04 03:31 PM


All times are GMT +1. The time now is 08:36 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"