cross hair

J

johnpotter94501

i am a teacher and use excell for grades . Names on top assignments on the
right side. i am trying to make cross hairs what ever cell i click into i
will see a color line vertical and horsonal to help me make sure the right
grades are entered. i have office 2007 pro.
 
R

Rick Rothstein

Does this SelectionChange event code do what you want...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Union(Target.EntireColumn, Target.EntireRow).Interior.ColorIndex = 40
End Sub

Change the ColorIndex value to suit your own personal tastes.
 
R

Rick Rothstein

It occurs to me that you may not know how to implement the code I gave you
earlier. Right click the tab at the bottom of the worksheet where you want
to create the cross hair indicator, select View Code from the popup menu
that appears and then copy/paste the code I gave you earlier into the code
window that appeared.
 
M

Max

Rick, Thanks for sharing your crosshair sub. Is there a way in which we can
control that worksheet sub's activation/deactivation via say, another sub
assigned to a button? This is meant to enable "normal" mode (ie with
crosshair sub deactivated) so that we can work on the sheet as per normal,
with undo available, and switch-over to activate the crosshair sub whenever
required. Thanks
 
R

Rick Rothstein

Here is one way to do that. Replace the code I posted earlier with the all
the code I have marked below instead. To activate/deactivate the crosshair
mode, just double click any cell on the worksheet... if the crosshair is
visible, it will be turned off... if the crosshair is not visible, it will
be turned on.

'*************** START OF CODE ***************
Dim CrosshairModeOn As Boolean

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Cancel = True
CrosshairModeOn = Not CrosshairModeOn
If CrosshairModeOn Then
Union(Target.EntireColumn, Target.EntireRow).Interior.ColorIndex = 15
Else
Cells.Interior.ColorIndex = 0
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If CrosshairModeOn Then
Cells.Interior.ColorIndex = 0
Union(Target.EntireColumn, Target.EntireRow).Interior.ColorIndex = 15
End If
End Sub
'*************** END OF CODE ***************
 
J

johnpotter94501

Rick the code worked fine except when i close the file it won't work again .
also can i defult this to the workbook john
 
R

Rick Rothstein

Which code are we talking about, the SelectionChange event code (which
should work when you open the workbook again) or the macro version (which
requires you to start it each time you open the workbook)? As for defaulting
the code to the workbook "john"... if you put it in that workbook, it should
be available whenever you open that workbook. Perhaps if you can provide
more detail describing what you want to happen, then we won't have to try
and guess at what you are ultimately looking for.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top