|
-
Apr 8th, 2003, 05:16 AM
#1
Thread Starter
Lively Member
Highlighting column and row.
Hi, let's assume everytime Im clicking a cell in Excel, It should intersect the column and row...It can be highlighted with any color or simply default...how to do it..?thanks for the help.
-
Apr 8th, 2003, 05:56 AM
#2
VB Code:
[color="#0000A0"]Private[/color] [color="#0000A0"]Sub[/color] Worksheet_SelectionChange([color="#0000A0"]ByVal[/color] Target [color="#0000A0"]As[/color] Range)
Cells.Interior.ColorIndex = 0
Columns(Target.Column).Interior.ColorIndex = 36
Rows(Target.Row).Interior.ColorIndex = 36
[color="#0000A0"]End[/color] [color="#0000A0"]Sub[/color]
-
Apr 8th, 2003, 06:27 AM
#3
Thread Starter
Lively Member
I've commented out the first line coz i do not want my original color to be erased...but for this:
PHP Code:
Columns(Target.Column).Interior.ColorIndex = 36
Rows(Target.Row).Interior.ColorIndex = 36
whenever i remove my cursor to other cell, the yellow lines seems to be jus there. they do not disappear away.how can u change it? What I actually wanted was only the y and -x axis but urs has also -y and x axis..can it be removed?? Thanks for helping.
-
Apr 8th, 2003, 08:11 AM
#4
First off, the Cells.Interior.ColorIndex = 0" line clears all of the cells colours which have been set, i.e. for every cell in the active worksheet, the interior colour is set back to the default white background.
Next up, try this code:
[Highlight=VB]
VB Code:
[color="#0000A0"]Private[/color] [color="#0000A0"]Sub[/color] Worksheet_SelectionChange([color="#0000A0"]ByVal[/color] Target [color="#0000A0"]As[/color] Range)
[color="#0000A0"]Dim[/color] rngActiveCell [color="#0000A0"]As[/color] Range
[color="#0000A0"]Set[/color] rngActiveCell = Range(CStr(Mid(ActiveCell.Address, 2, CInt(InStr(Right(ActiveCell.Address, _
CInt(Len(ActiveCell.Address) - 1)), "$") - 1))) & ActiveCell.Row)
Cells.Interior.ColorIndex = 0
Range(CStr(Mid(Target.Address, 2, CInt(InStr(Right(Target.Address, CInt(Len(Target.Address) - 1)), _
"$") - 1))) & "1:" & CStr(Mid(Target.Address, 2, CInt(InStr(Right(Target.Address, _
CInt(Len(Target.Address) - 1)), "$") - 1))) & Target.Row).Interior.ColorIndex = 36
Range("A" & Target.Row & ":" & CStr(Mid(Target.Address, 2, CInt(InStr(Right(Target.Address, _
CInt(Len(Target.Address) - 1)), "$") - 1))) & Target.Row).Interior.ColorIndex = 36
rngActiveCell.Select
[color="#0000A0"]End[/color] [color="#0000A0"]Sub[/color]
Last edited by alex_read; Apr 8th, 2003 at 08:15 AM.
-
Apr 8th, 2003, 10:12 AM
#5
Thread Starter
Lively Member
Thanks for ur codes....Im having problems when I need to use it over a pivot table which is "protected". It needs to be.. coz I do not want users to make changes to it..Anyway,thanks for ur help n if I have any prob on the way, I'll get back to u buddy..
Cheers
ITboy
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|