View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
KarenY KarenY is offline
external usenet poster
 
Posts: 11
Default Active cell with a "crosshair" indicator ?

I am familiar with recording and running macro but not with VBA-modules.
I followed your instruction.
I pasted starting with "Public NotNow as Boolean" to the workbook - nothing
happens when I run the "HiteOn".
Then I realized I might have to paste the "Private Sub
Worksheet_SelectionChange(ByVal Target As Range)...etc" to the worksheet, so
I did the "paste" - again, nothing happens when I run the "HiteOn".

I am sorry being "stupid".

thanks
Karen

"Tom Hutchins" wrote:

My guess is that you pasted the Public variable and subroutines into the
ThisWorkbook module. That won't work; you have to insert a VBA module. In the
Visual Basic Editor, select Project Explorer from the View menu & make sure
the Project Explorer window is displayed. You should see bold text that says
VBAProject (ABC.xls), where ABC is the name of your workbook. Click the
VBAProject with the name of your workbook, then select Module from the Insert
menu. Paste the code I sent you, starting with "Public NotNow as Boolean",
into the new code module. If you had pasted it into the ThisWorkbook module
earlier, delete it there.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Hutch

"KarenY" wrote:

Thanks Tom,

When I turned on the Macro.
I got "Compile error - Sub or Function not defined".
The "Call HiliteCells" was highlighted for this Compiled error in the
worksheet ?

What shall I do ?

karen

"Tom Hutchins" wrote:

Here is one way to do that - including a way to turn the highlighting on or
off. In the code module for each worksheet where you want this to happen,
paste this code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Call HiliteCells(Target)
End Sub

In a VBA module in the same workbook, paste this code:

Public NotNow As Boolean

Public Sub HiliteOn()
NotNow = False
End Sub

Public Sub HiliteOff()
NotNow = True
Cells.Interior.ColorIndex = xlColorIndexNone
End Sub

Public Sub HiliteCells(Target As Range)
If NotNow = False Then
Cells.Interior.ColorIndex = xlColorIndexNone
Target.EntireRow.Interior.ColorIndex = 36
Target.EntireColumn.Interior.ColorIndex = 36
End If
End Sub

(ColorIndex 36 is light yellow. Change to whatever you like).

To start highlighting on that worksheet, run the HiliteOn macro. To stop it,
run the HiliteOff macro. These could be assigned to toolbar buttons.

Hope this helps,

Hutch

"KarenY" wrote:

Hi, could anybody please help -
if I put the cursor on an active cell on a spreadsheet, I want the
corresponding row and column being highlighted (i.e. like a crosshair) - how
do I do that ?

appreciate your answer,
thanks
Karen