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)?
0
JingleRock
6/1/2010 6:25:47 PM
excel.programming 6508 articles. 2 followers. Follow

5 Replies
1224 Views

Similar Articles

[PageSpeed] 5

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
0
Dave
6/1/2010 6:32:48 PM
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?

0
JingleRock
6/1/2010 8:30:26 PM
The Change Event is working now.  Again, any ideas?

0
JingleRock
6/1/2010 9:01:04 PM
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
0
Dave
6/1/2010 9:27:50 PM
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" <cegrob@comcast.net> wrote in message 
news:fede0c39-a26b-401e-b1d0-d18238c59dd5@f14g2000vbn.googlegroups.com...
>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)? 


0
L
6/1/2010 11:00:06 PM
Reply:

Similar Artilces:

Don't know where else to put q's. 2 questions. 11g Dongle and wire
What is and Acer WLAN 11g USB Dongle? It is some program that is on my computer and pops-up at start-up. I'v double clicked it, and nothing happens. I went on Acers site, and I can find nothing. Even some freeware mentions it, but they only talked about the freeware, not this WLAN 11g itself. And how can I tell if I have wireless or not. This seems like a nobrainer, you have it or not. But some documents on my computer mention wireless internet surfing in programs that are there. I use a high speed connection through an external modem that connects to my comuter and the w...

Import from Notepad delimited text
Is it possible to import from Notepad . There is a table with pipe delimiters that is automatically generated in a .dat text file using Notepad which I would like to import / link into my database daily. This .dat file arrives via email each day as an attachment. I tried saving the .dat file into a .txt extension but ACCESS wouldn't recognize it . I currently need to use the excel text wizard everyday to convert this file into an .xls format . I then have my access 2003 database linking to this ..xls file. Although I know how to convert this .dat file there are others ...

External data link change
Hi, I've a sheet linked to an external data on the net, and I would like that a cell in this sheet to indicate the last date and time it was updated, the simplest way the better but I can do some programming too. Thanks for your attention, -- Domingos Junqueira No need of help any more, I solved the question. Thanks again ...

Why does the change change to a number?
Hi all, I've noticed something wierd and always wondered WHY it happens. When you type a date into a cell, and then change the Formatting of it to a 'general' cell, it turns into a number. How does it come up with that number? What is the significance? i.e. type today's date of "12/7/2007" - change it to a 'General' format, and it then says "39423". I'm a trainer of Excel and this question always comes up. I'm curious myself too. Thanks! Joe It's the number of days since January zero 1900 using Excel default for windows (M...

changing the way Excel displays selected cells
Is there a way to change the way Excel displays selected cells? I'm interested in viewing all the selected cells highlighted (with light blue for instance), but by default excel highlights all the cells but not the first one the same occurs when you define a range with no adyacents cells Your definition of the display is not quite correct. Excel highlights the current cell, Excel also highlights a selecte range. The currently selected cell is generally the first of a range, bu press enter and the current cell changes and becomes the second, the third etc in the range. You cannot...

Sum numbers in a column beyond a certain row, how to?
How to sum numbers in a column beyond a certain row? hi, i don't know if i understand your question correctly, =Sum(A1:A10) -- isabelle Le 2012-02-15 01:25, marsup a �crit : > How to sum numbers in a column beyond a certain row? On Feb 17, 11:30=A0am, isabelle <i...@v.org> wrote: > hi, > > i don't know if i understand your question correctly, > > =3DSum(A1:A10) > > -- > isabelle > > Le 2012-02-15 01:25,marsupa =E9crit : > > > > > > > > > How to sum numbers in a column beyond a certain row? Thanks Isabelle, I a...

Track Changes
How do i remove the track changes in outlook? When i press "Enter", a symbol that represents "Enter" will appears. Same for space etc. ...

DST changes for Exchange 5.5
I noticed the 2007 DST Calendar Update "Exchange tool" is available now: http://support.microsoft.com/kb/930879 This will seemingly take care of calendars for mailboxes still on Exchange 5.5 servers, as Exchange 5.5 is listed as "compatible" . However would this address the CDO issues such as BlackBerry users and OWA users still on Exchange 5.5 ? Thanks in advance, Itrcb4 On Mon, 12 Feb 2007 14:31:00 -0800, itrcb4 <itrcb4@discussions.microsoft.com> wrote: >I noticed the 2007 DST Calendar Update "Exchange tool" is available now: > >http://su...

more on VBA function name change
I thought I'd start a new thread since I haven't received any replies to my first one... To recap: I've declared a function in a module using mixed case: Function TMDE_Category (FormName As Form) I noticed recently that it appeared in the module as Function tmde_category(FormName As Form) I changed it back to the mixed case declaration, saved the module, exited the app, reopened it and looked. The function had changed back to the all lowercase declaration. Things I've tried since the original post: Using the databse documenter, I selected all ob...

Hidden rows unhide themselves when formulas are written
I have a worksheet with many hidden rows & columns. However, when I try to write a formula in this worksheet, these hidden rows & columns automatically unhide themselves. Is there any way to disable this? ...

Can't Publish changes with Deploy Manager
After a migration process, I can't publish the changes made on CRM. When I try do this in Deploy Manager I get the follow error: ---------------------------------------------------------------------------- ----- Publish done with errors. See the event log to get deitails NETRA-INOVACAO: ***Error*** Failed to download XSL template files from Web Server ---------------------------------------------------------------------------- ----- Can somebody help me? I don't know if the migration process have any relationship with the error. Thank you for pay attention. []'s Vin�cius Pitta...

VLOOKUP: Retrieving Values
Vlookup: I am trying to lookup a value ( SCOTLAND ) on a spreadsheet called ( Data ) in order to populate ceratin cells on my other spreadsheet ( Spreadone ). If the value (SCOTLAND) is located in (Data) I want it to copy the values of specific cells (not all of them ) from the same row into ( Spreadone ). So : CHECK COLUMN N (CLASS) IN SPREADSHEET (DATA) FOR STRING (SCOTLAND) IF THE STRING = SCOTLAND THEN IN SPREADSHEET (Spreadone) POPULATE CELL A7:A25 = ACCOUNT NO (from Data) CELL B7:B25 = CLIENT (from Data) CELL C7:C25 = CUSIP (from Data) CELL D7:D25 = QTY (from Data) CELL E7:E25...

Convert dates stored as text
I have Excel 2007 in English, but I sometimes receive data that comes from another applicationes, so dates are stored as text because they come in following format: dd/mm/yyyy. And I have the format mm/dd/yyyy. So, in the same column, I have dates stored as dates, and dates stored as text. Which is the easiest way to convert them all to date format? Thanks in advance. Regards, Emece.- Be careful. I'd bet that those values that come in as real dates aren't what the original data represent. For instance, if you have two values: 25/12/2010 and 01/02/2010 The...

How to change icon for my application
Hi, I am currently developing an application on visual studio 6.0, and i wish to change the MFC icon on my application header. Anyone can help? Thank you. Raed Sawalha wrote: > Hi, I am currently developing an application on visual studio 6.0, and i > wish to change the MFC icon on my application header. Anyone can help? Thank > you. > > Open the icon resource for editing by double clicking. Then notice the control just above the editing grid that lets you switch between editing the large icon and editing the small one. -- Scott McPhillips [VC++ MVP] thanx that work...

How to change newsgroup message font
Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? regards "nobody" wrote in message news:EWTao.39493$GF5.7129@hurricane... > Like many other ribbon based programs I sometimes struggle to find how to make a change. This time its how to change the font just for newsgroup messages? Newsgroup messages are usually plain text. The font used is that selected at [no name tab] > Options > Mail > Read > Fonts for the encoding specified for the messag...

Taking the Mode based on cell value
Could you provide a few more details about what you want to do? -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "sip8316" <sip8316@discussions.microsoft.com> wrote in message news:E3F4DE24-C5E8-4911-96E6-E61A1E56DEF0@microsoft.com... > ...

Border with text
I'm trying to make a border using text. I want to repeat the same phrase over and over again. Idealy, I'd like the words to make a rectangular border for a sign... and when it hit the corner of the page, the phrase would continue down the next angle, and so on, until it made a box. Does anyone have any ideas on how to do this? WordArt would be your only option. If you had a draw program... Serif has a free draw application. http://www.freeserifsoftware.com/ OpenOffice is free and has a draw feature. www.openoffice.org I have a method using WordArt on my web site that might be...

Notify change of email address when changing ISP
How do I notify my entire address book of an email address when I change ISP's? Thanks By sending a mail to everyone ? If you do so, please use BCC for the adresses, this way you won't spread everybody's e-mail adres to everybody. Niels Bob Baker wrote: > How do I notify my entire address book of an email address when I change ISP's? > Thanks ...

Change a formula to an acual number
I want to change the formula I have created to the number it has created Example: Cell A1 is the number 1. Cell A2 is the formula =a1+1 creatin the number 2. I want this to be a two not a formula. Any ideas? Laura, copy, then paste special, valves -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2000 & 97 ** remove news from my email address to reply by email ** "Laura" <anonymous@discussions.microsoft.com> wrote in message news...

How do I use cond format formula to set cell text and color?
Using MS Excel 2003: As and example, I entered into Conditional Format for cell B1: "Formula is", IF(A1="","Test",""). For true condition, the format is set to fill Yellow and font color red. I'm expecting cell B1 to display, "Test" in red text with yellow background when A1 is blank, but it does not work. No errors are displayed. Any ideas? in my experience you can only set the format,you cant have the word test show up.Apply the format condition only using =A1="" and put a seperate if statement in the cell.If it blank ...

Text Functions
I'm trying to split a text string ... Apart from it not working quite right yet! I'm sure I've over complicated it. Base Data "Path": \\SERVER\X$\data\Team Name\Personal Data\JOE BLOGGS\mail\ \\SERVER\X$\ \\SERVER\X$\RECYCLER\ \\SERVER\X$\$Extend\ \\SERVER\X$\$Extend\Test I'm trying to split into High Level Directory (HLD) / Team/User Directory (TUD) / Team/User Sub-Directory HLD: =IFERROR(SUBSTITUTE(LEFT(Path,(SEARCH("\",Path,(SEARCH("\",Path,(SEARCH("X$",Path,1))+3))+1))),"\\SERVER\X$\",""),SUBS...

Problem Changing an Investment Name
I am trying to change an investment name and Money 2006 tells me "The name or symbol 'TRP Spectrum Income' has already been used for a deleted investment. Please enter a different name." When I go to delete investments the name does not appear! Any ideas on how I get Money to accept the name change? This is the first time I have run into this situation and I have made numerous name changes in Money over the years. In microsoft.public.money, Ken wrote: >I am trying to change an investment name and Money 2006 tells me "The name >or symbol 'TRP Spec...

how do i find color saffron in pub2003
old pub98 had color boxes to choose from now all i get is a color wheel impossible to find a specific color like saffron. please help chefmstobey1968 wrote: > old pub98 had color boxes to choose from now all i get is a color wheel > impossible to find a specific color like saffron. please help Make sure you go to Tools > Options and select Show basic colors in color palette -- Brian Kvalheim Microsoft Publisher MVP http://www.publishermvps.com ~pay it forward~ This posting is provided "AS IS" with no warranties, and confers no rights. ...

Total row in report
I have a spreadsheet that I would like to total at the bottom. But I don't want to have to keep inserting rows when it fills up. Is there a way to have the total at the very bottom of the spreadsheet, but still have it print out on a report with all the data? Hi The usual way around this is to have a Totals line at the top of the list, under the titles, and then use Window/Freeze Panes so you can see it all of the time. -- Andy. "Moo" <moo@nospam.com> wrote in message news:LzT4e.5261$jR3.8@edtnps84... >I have a spreadsheet that I would like to total at the b...

How to copy a column of values into another column where the cells are merged
Hi, I have a sheet with a column that lists some values. I also have a second sheet that has a column where the cells are merged every 4 rows. I need to copy the values of the first sheet into the merged cells, but when I do, I only see every fourth value on the merged cells. Is there a formula or any other way that I can use to be able to copy all the values from the first sheet into the second sheet each value on a different group of merged cells? Thanks! Assume you have values in A1:A5 of Sheet1 that you want to copy into Sheet2, where A1:A4, A5:A8, A9;A12 etc are merged. Put this formul...