+ Reply to Thread
Results 1 to 6 of 6

Highlight Cell on Cursor Movement

Hybrid View

  1. #1
    Registered User
    Join Date
    06-22-2014
    Location
    Indore, M.P., India
    MS-Off Ver
    2010
    Posts
    26

    Highlight Cell on Cursor Movement

    I want to do a arrangement for a file like this " wherever cursor moves in excel that particular cell will highlight with color and once it goes to some other cell that last highlighted cell will come as a ordinary cell"

    Pls Help....

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,065

    Re: Highlight Cell on Cursor Movement

    Maybe base something on this:

    http://www.extendoffice.com/document...nd-column.html
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    06-22-2014
    Location
    Indore, M.P., India
    MS-Off Ver
    2010
    Posts
    26

    Re: Highlight Cell on Cursor Movement

    No.. this is highlighting Concern Row & Column but i need only highlight that particular active cell.

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: Highlight Cell on Cursor Movement

    Try this.....
    Right Click on Sheet Tab --> View Code --> Paste the code given below in the code window --> Save your workbook as Excel Macro-Enabled Workbook.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveSheet.Cells.Interior.ColorIndex = xlNone
    Target.Interior.ColorIndex = 6
    End Sub
    Is this what you are trying to achieve?
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  5. #5
    Registered User
    Join Date
    06-22-2014
    Location
    Indore, M.P., India
    MS-Off Ver
    2010
    Posts
    26

    Re: Highlight Cell on Cursor Movement

    Sir, it's very good code but it's removing the color of all the color filled cell.

  6. #6
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Highlight Cell on Cursor Movement

    Hi,

    Try the attached file. If you want, you can select a MASTER CELL that contains the color you want to use. If there is no MASTER CELL color, then the default ColorIndex (27 = bright yellow) will be used.

    Lewis

    Code follows from ThisWorkbook module:
    Option Explicit
    
      Private Const myGblActiveCellColorIndexMasterSheetNAME As String = "Sheet1"
      
      '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      'Set the value of the next line to "" if there is NO MASTER CELL (the default value will be used)
      '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
      Private Const myGblActiveCellColorIndexMasterCELL As String = "D5"
    
      Private Const myDefaultActiveCellColorINDEX = 27     'Set default to bright Yellow
    
      Private myGblActiveCellColorIndex As Long
      Private myGblLastActiveCell As String
      Private myGblLastActiveSheet As String
    
    
    Private Sub Workbook_Open()
    
      'Get the last used Worksheet and Cell from the current location of the Active Cell
      myGblLastActiveSheet = ActiveSheet.Name
      myGblLastActiveCell = ActiveCell.Address(False, False)
        
    End Sub
    
    
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
      'This colors the active cell and saves the value for future use
      
      Dim iError As Long
    
      If myGblLastActiveSheet = myGblActiveCellColorIndexMasterSheetNAME And Target.Address(False, False) = myGblActiveCellColorIndexMasterCELL Then
        'do nothing - do not uncolor the MASTER Color cell
      Else
      
        'Get the Active Cell Color Index from the designated cell on the Master Color Index Sheet
        'If there is an error or no value, use the default value
        On Error Resume Next
        myGblActiveCellColorIndex = Sheets(myGblActiveCellColorIndexMasterSheetNAME).Range(myGblActiveCellColorIndexMasterCELL).Interior.ColorIndex
        iError = Err.Number
        If myGblActiveCellColorIndex = xlNone Or iError <> 0 Then
          myGblActiveCellColorIndex = myDefaultActiveCellColorINDEX
        End If
        On Error GoTo 0
        
        'Set the color index of the Active cell - because it is NOT the Master Sheet and Master Color Cell
        Target.Interior.ColorIndex = myGblActiveCellColorIndex
      
        'Clear the previous Active Cell of color (unless it is the first Active Cell)
        If Len(myGblLastActiveSheet) > 0 Then
          Sheets(myGblLastActiveSheet).Range(myGblLastActiveCell).Interior.ColorIndex = xlNone
        End If
      
        'Save the Active Sheet Name and Active Cell Name for future use
        myGblLastActiveSheet = Sh.Name
        myGblLastActiveCell = Target.Address(False, False)
        
      End If
      
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Why cursor movement is closing cell during edit
    By Chubster in forum Excel General
    Replies: 1
    Last Post: 12-29-2013, 07:04 PM
  2. Automatic movement of cursor into next cell
    By davidcrawt in forum Excel General
    Replies: 2
    Last Post: 01-29-2013, 08:20 AM
  3. Cursor Movement to specific Cell in MS Excel 2007
    By jacksonmathews in forum Excel General
    Replies: 9
    Last Post: 02-23-2010, 03:05 PM
  4. [SOLVED] Recording macros....record cursor movement not cell address?
    By tim m in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-22-2006, 03:35 PM
  5. [SOLVED] Cursor movement
    By Ann Calantzis in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-25-2005, 12:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1