LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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!
 
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 06:49 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"