Library code snippets

Excel Coloured Cursor

The following code could be placed in either the Selection_Change procedure of a worksheet, or the SheetSelectionChange procedure of a workbook.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

        Cells.Interior.ColorIndex = xlColorIndexNone<br>
        Selection.Interior.ColorIndex = 8

    End Sub

This code works for sheets with no fills in the background, as everytime the selection changes it makes all the cell interior colours equal to no fill.  Different background colours could be substituted in instead of xlColorIndexNone if necessary.   The colour of the cursor can also be changed (8 is cyan).  See VBA help for color indexes.

Comments

  1. 01 Jun 2008 at 18:04

     This is a cool code, but the draw back is, you are not able to copy and paste with this worksheet function in the normal way,

    you would have to use the clip board

    example

    to copy a cell

    Ctrl+c+c copies to the clipboard

     

    Then you would have to use the clipboard to paste

     

    or if you wanted to use code

    Range("A1").Copy Destination:=Range("G1")
     

  2. 03 Dec 2003 at 16:55
    gravitycure had a great code tip.  Modification to highlight row:


    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

           Rows.Cells.Interior.ColorIndex = xlColorIndexNone
           Selection.EntireRow.Cells.Interior.ColorIndex = 8

    End Sub
  3. 11 Mar 2003 at 14:11


    I believe this will give you just columns A through I



    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
           Cells.Interior.ColorIndex = xlColorIndexNone
         Range("A" & Selection.Row, "I" & Selection.Row).Interior.ColorIndex = 19
               
       End Sub


    regards,
    David

  4. 07 Feb 2003 at 19:15

    I like your colored Cursor but I need to highlight the whole row A thru I
    as the cursor is moved downward or upward as Colum I contains Names
    and I need to know if I am on the Right Name when I type an Entry.
    I know I could probably put the names in the A Column But when Typeing in the H Colomn I would be back with the same problem.
    Any Ideas?


    Thanks

  5. 01 Jan 1999 at 00:00

    This thread is for discussions of Excel Coloured Cursor.

Leave a comment

Sign in or Join us (it's free).

 Gravitycure

Want to stay in touch with what's going on? Follow us on twitter!