Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Change color of row (Col A thru Col Q) based on text value in Col J

I am using David McRitchie's code for changing color of entire row
based on contents based on a specified cell text value:
'Target.EntireRow.Interior.ColorIndex = 36'.
This works fine; however, I only want to change color in the first 17
cells in each of the affected rows. How do I do this?
Also, I am confused: do I want the stmt 'Application.EnableEvents =
True' at the top of my coding in the 'Worksheet_Change' event coding
(occupies the Sheet1 Module)?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change color of row (Col A thru Col Q) based on text value in Col J

One way:

Target.EntireRow.resize(1,17).Interior.ColorIndex = 36

JingleRock wrote:

I am using David McRitchie's code for changing color of entire row
based on contents based on a specified cell text value:
'Target.EntireRow.Interior.ColorIndex = 36'.
This works fine; however, I only want to change color in the first 17
cells in each of the affected rows. How do I do this?
Also, I am confused: do I want the stmt 'Application.EnableEvents =
True' at the top of my coding in the 'Worksheet_Change' event coding
(occupies the Sheet1 Module)?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Change color of row (Col A thru Col Q) based on text value in ColJ

Dave,

Thanks for your response and suggestion.
For some reason, my Worksheet_Change event is not working at all.
For example, I commented-out my Sheet1 Module and replaced it with:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 3
End Sub

Then, I enter text in various cells of Sheet1 and there is zero color
change. Any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Change color of row (Col A thru Col Q) based on text value in ColJ

The Change Event is working now. Again, any ideas?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Change color of row (Col A thru Col Q) based on text value in Col J

My bet is that you didn't put the code in the correct module.

In excel, Rightclick on the worksheet tab that should have this behavior.
Select view code
paste your procedure into the code window that just opened.

And make sure that macros are enabled and events are enabled, too.

Inside the VBE:
hit ctrl-g (to see the immediate window)
type:
application.enableevents = true
and hit enter.

Then back to excel to test.

JingleRock wrote:

Dave,

Thanks for your response and suggestion.
For some reason, my Worksheet_Change event is not working at all.
For example, I commented-out my Sheet1 Module and replaced it with:

Private Sub Worksheet_Change(ByVal Target As Range)
Target.Interior.ColorIndex = 3
End Sub

Then, I enter text in various cells of Sheet1 and there is zero color
change. Any ideas?


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default Change color of row (Col A thru Col Q) based on text value in Col J

If you want to highlight other than the first to the 17th you could try
something like this.

Highlights the row from column B to K which you can change by tweeking the
code and only works in the Range("B8:K22") that is set to Data in the code,
which you can also change.

You can probably figure out the Offset/Resize changes to suit your chosen
range.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Data As Range
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim cells As Range
i = 2
j = 8
k = ActiveCell.Column()
Set Data = Range("B8:K22")

Data.Interior.ColorIndex = xlNone

If ActiveCell.Row < 8 Or ActiveCell.Row 22 Or _
ActiveCell.Column < 2 Or ActiveCell.Column 11 Then
Exit Sub
End If

ActiveCell.Offset(0, -(k - i)). _
Resize(1, 10).Interior.ColorIndex = 36 '26

End Sub

HTH
Regards,
Howard


"JingleRock" wrote in message
...
I am using David McRitchie's code for changing color of entire row
based on contents based on a specified cell text value:
'Target.EntireRow.Interior.ColorIndex = 36'.
This works fine; however, I only want to change color in the first 17
cells in each of the affected rows. How do I do this?
Also, I am confused: do I want the stmt 'Application.EnableEvents =
True' at the top of my coding in the 'Worksheet_Change' event coding
(occupies the Sheet1 Module)?



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 color in excel based on text input? giffjr13 New Users to Excel 4 April 5th 23 01:05 PM
Change Text Color in one cell based upon entry in referenced cell Tee Excel Discussion (Misc queries) 3 September 12th 08 10:07 PM
Want to change color based on Text, NOT using Conditional Formatin Mitch Excel Programming 3 September 20th 07 08:30 PM
How to code so cells or text automatically change color based on . lisamariehewson Excel Worksheet Functions 2 February 25th 05 10:10 PM
change text color based on logical test T3nMan Excel Worksheet Functions 1 January 19th 05 04:30 PM


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