T
TJV
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!
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!