Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
TJV TJV is offline
external usenet poster
 
Posts: 2
Default Highlight selected cells if text is in certain column

I've been sorting through the message boards and I can't quite find a
subject to address this issue. I'm working with Excel 97.

I have a spreadsheet that I'm trying to get to highlight certain cells
in the corresponding row based on the text typed in the cells of
column "V".

Column "V" is titled "Delete". Users can either type a "x" or leave it
blank. If they type an "x" I want it to black out certain cells on the
corresponding row. If they leave it blank or delete the "x" to make it
blank, then I want it to maintain its original formatting.

Here's a macro that I found in the newsgroups that gets me partially
to where I need to be. This macro blacks out the appropriate cells
when a cell in column "V" is selected, which is great, but when I
select another cell in column "V", it takes the black off that row and
blacks out the row where the cell is selected. I want the row to black
out the appropriate cells when an "x" is typed rather than just
selecting the cell. Here's the macro:

Option Explicit
Dim LastRange As Range
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim thisRow As Long

If Target.Column = 22 Then
thisRow = Target.Row
If Not LastRange Is Nothing Then
LastRange.Interior.ColorIndex = 0
End If
Set LastRange = Range(Cells(thisRow, 22), Cells(thisRow, 46))
LastRange.Interior.ColorIndex = 1
ElseIf Not LastRange Is Nothing Then
If Intersect(Target, LastRange) Is Nothing Then
LastRange.Interior.ColorIndex = 0
End If
End If
End Sub

The second part of my problem is that my spreadsheet has certain
columns which are preformatted to color some columns green. I have a
macro that runs at the beginning of formatting which selects certain
columns and colors them green (columns AM:AO). Yet when I black out
the row by selecting a cell in column "v" (using the above macro),
then I lose the green formatting on my columns for the row that was
blacked out. How do I get it to revert back so that it has green on
those columns again? Is there like an "undo" formatting if I have an
"x" in the column and then later delete the "x" or do I have to write
code so that if it is "" that I need to color certain cells in that
row green again?

I've seen macros to black out the whole row, but I don't want to do
that because I have info in columns A:U that will be hidden from the
user but that I will need to see. If they are blacked out by the user
typing an "x" then I can't see this data. That's why I only want to
black out certain cells on that row.

Help! I've been using the message boards for a while and have found
some great stuff to use but I can't find something to address this.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Highlight selected cells if text is in certain column

You need to drop the macro approach and use Conditional formatting.

Select the cells you want blacked out

Then go to Format=Conditional formatting
Change Cell Value is to
Formula is

in the text box put in. Assume we are on Row 2 or you have select multiple
rows (and columns) but the activecell is in row 2

=$V2="X"
then click on format and select the pattern tab. Click on the black color.

Then OK your way out.

When an X is in column V, those cells in that row will appear black. When
you remove the X, they will return to their original formatting.

--
Regards,
Tom Ogilvy

"TJV" wrote in message
om...
I've been sorting through the message boards and I can't quite find a
subject to address this issue. I'm working with Excel 97.

I have a spreadsheet that I'm trying to get to highlight certain cells
in the corresponding row based on the text typed in the cells of
column "V".

Column "V" is titled "Delete". Users can either type a "x" or leave it
blank. If they type an "x" I want it to black out certain cells on the
corresponding row. If they leave it blank or delete the "x" to make it
blank, then I want it to maintain its original formatting.

Here's a macro that I found in the newsgroups that gets me partially
to where I need to be. This macro blacks out the appropriate cells
when a cell in column "V" is selected, which is great, but when I
select another cell in column "V", it takes the black off that row and
blacks out the row where the cell is selected. I want the row to black
out the appropriate cells when an "x" is typed rather than just
selecting the cell. Here's the macro:

Option Explicit
Dim LastRange As Range
Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim thisRow As Long

If Target.Column = 22 Then
thisRow = Target.Row
If Not LastRange Is Nothing Then
LastRange.Interior.ColorIndex = 0
End If
Set LastRange = Range(Cells(thisRow, 22), Cells(thisRow, 46))
LastRange.Interior.ColorIndex = 1
ElseIf Not LastRange Is Nothing Then
If Intersect(Target, LastRange) Is Nothing Then
LastRange.Interior.ColorIndex = 0
End If
End If
End Sub

The second part of my problem is that my spreadsheet has certain
columns which are preformatted to color some columns green. I have a
macro that runs at the beginning of formatting which selects certain
columns and colors them green (columns AM:AO). Yet when I black out
the row by selecting a cell in column "v" (using the above macro),
then I lose the green formatting on my columns for the row that was
blacked out. How do I get it to revert back so that it has green on
those columns again? Is there like an "undo" formatting if I have an
"x" in the column and then later delete the "x" or do I have to write
code so that if it is "" that I need to color certain cells in that
row green again?

I've seen macros to black out the whole row, but I don't want to do
that because I have info in columns A:U that will be hidden from the
user but that I will need to see. If they are blacked out by the user
typing an "x" then I can't see this data. That's why I only want to
black out certain cells on that row.

Help! I've been using the message boards for a while and have found
some great stuff to use but I can't find something to address this.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Highlight selected cells if text is in certain column

i have a similar problem but slightly more complicated.

i want to turn the selected cells a certain colour of the date i
column H is in the past, i.e. before today.

the date format in the H column is custom dd-mmm-yy format.

any ideas

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Highlight selected cells if text is in certain column

Hi
you may use conditional format:
- select your cells
- goto 'Format - conditional Format'
- enter the formula
=$H1<TODAY()

--
Regards
Frank Kabel
Frankfurt, Germany

i have a similar problem but slightly more complicated.

i want to turn the selected cells a certain colour of the date in
column H is in the past, i.e. before today.

the date format in the H column is custom dd-mmm-yy format.

any ideas?


---
Message posted from http://www.ExcelForum.com/

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Highlight selected cells if text is in certain column

seems to work except it sets the entire table to the colour i specif
based on one row at the top, rather than setting each row based o
whether the H column in THAT row is <today or not.

any way to easily specify it should do it like this without having t
set conditional format individually on every row in the tables

--
Message posted from http://www.ExcelForum.com



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Highlight selected cells if text is in certain column

Hi
just select all rows you require (starting in row one) and enter the
formula
=$H1<TODAY()
the row_index will change automatically

--
Regards
Frank Kabel
Frankfurt, Germany

seems to work except it sets the entire table to the colour i specify
based on one row at the top, rather than setting each row based on
whether the H column in THAT row is <today or not.

any way to easily specify it should do it like this without having to
set conditional format individually on every row in the tables?


---
Message posted from http://www.ExcelForum.com/


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
Highlight selected cells only RJJ Excel Worksheet Functions 4 May 5th 09 06:03 PM
Cells do not highlight when selected. Jay Excel Discussion (Misc queries) 1 November 12th 08 01:41 PM
Cells Won't Highlight when selected Javabumb Excel Discussion (Misc queries) 2 June 9th 08 07:36 PM
Trying to highlight (bold,red) selected text within range tmayhall Excel Discussion (Misc queries) 0 August 21st 06 10:03 PM
How to highlight row and column of the selected cell Row_Column_Highlight Excel Discussion (Misc queries) 2 February 27th 05 10:48 PM


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