Worksheet_SelectionChange
Hi Bill
some inherent darwbacls of using this kind of code :-)
some solution ideas:
1. You may add some code to the workboo_beforeclose event which will
reset the colors in your sheet to normal. This will deal with the
problem that one row remains colored
2. Not muh chance against that as the selection_change event colors the
new row and this clears the clipboard contents
--
Regards
Frank Kabel
Frankfurt, Germany
"Bill Oertell" schrieb im Newsbeitrag
...
I have a spreadsheet with the following macro in several sheets. It
changes the
fill color of the active row to yellow. It's quite handy, as the
sheet is a bit
wide so it helps me keep track of what row I'm working with. It has
only one
drawback (well, two). When I first open the workbook or first
activate another
sheet, the active row is, of course, yellow, but when I move off of
that row or
click on another row, the initial row remains yellow. The sheet then
has two
rows that are yellow and remains that way unless I scroll through the
active
row. That is, make the initial active row active again and then go
to another
row.
Also, I can't copy (or cut) and paste from one cell to another on
the same
sheet and if I want to copy to another sheet, I first have to
pre-select where I
want to copy to.
Here's the code. It's adapted from (I believe) Chip Pearson's
website. My
apologies if it's someone else. Any help would be gladly
appreciated.
Dim z As Long
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
'Exit Sub
ActiveCell.EntireRow.Interior.ColorIndex = 6
If z = Empty Then
z = ActiveCell.Row
ElseIf Not z = ActiveCell.Row Then
Rows(z).EntireRow.Interior.ColorIndex = xlColorIndexNone
End If
z = ActiveCell.Row
End Sub
|