Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Macro to change cell colour based on words

I have a cell identified by either the word "Unbene" or the interior cell
colour.

I want to write a macro that will identify that cell and then colour 9 cells
in the same row.

The word is in cell C and I want cells A-I change to a colour I designate.

Is this clearer?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Macro to change cell colour based on words

This is kind of bulky, but it works.

Sub findWord()
lastRow = Cells(Rows.Count, 3).End(xlUp).Row
For Each c In Range("C2:C" & lastRow)
If c = "Unbene" Then
x = c.Address
Range("A" & Range(x).Row & ":I" & Range(x).Row).Interior.ColorIndex = 3
End If
Next
End Sub

"tiger" wrote:

I have a cell identified by either the word "Unbene" or the interior cell
colour.

I want to write a macro that will identify that cell and then colour 9 cells
in the same row.

The word is in cell C and I want cells A-I change to a colour I designate.

Is this clearer?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to change cell colour based on words

Maybe less bulky:

If c = "Unbene" Then
c.offset(0,-2).resize(1,9).Interior.ColorIndex = 3
End If

or even

c.entirerow.cells(1).resize(1,9).Interior.ColorInd ex = 3



JLGWhiz wrote:

This is kind of bulky, but it works.

Sub findWord()
lastRow = Cells(Rows.Count, 3).End(xlUp).Row
For Each c In Range("C2:C" & lastRow)
If c = "Unbene" Then
x = c.Address
Range("A" & Range(x).Row & ":I" & Range(x).Row).Interior.ColorIndex = 3
End If
Next
End Sub

"tiger" wrote:

I have a cell identified by either the word "Unbene" or the interior cell
colour.

I want to write a macro that will identify that cell and then colour 9 cells
in the same row.

The word is in cell C and I want cells A-I change to a colour I designate.

Is this clearer?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Macro to change cell colour based on words

Another
If only ONE, then find might be best. If not, use the loop provided or
FINDNEXT.

myrow=columns("c").find("Unbene").row
range(cells(myrow,"a"),cells(myrow,"i")).interior. colorindex=6

--
Don Guillett Excel MVP
SalesAid Software

"tiger" wrote in message
...
I have a cell identified by either the word "Unbene" or the interior cell
colour.

I want to write a macro that will identify that cell and then colour 9
cells
in the same row.

The word is in cell C and I want cells A-I change to a colour I designate.

Is this clearer?


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
Using CF to change colour in cell based on date? Steve[_26_] Excel Discussion (Misc queries) 4 March 21st 10 10:52 PM
how do i change cell text colour based on value in other cell Oscarrot Excel Worksheet Functions 2 July 20th 09 03:21 PM
change current cell colour based on the value of adjacent cell on other worksheet Rits Excel Programming 2 November 23rd 06 11:57 AM
How to change cell colour based on numer of months? Tiago Excel Programming 6 May 11th 06 01:20 PM
Change the colour of a bunch of cells, based on one cell. Craig & Co. Excel Programming 2 October 14th 04 06:28 AM


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