Highlight Selected Cell Without Using Conditional Formatting

Submitted by Ivan F. Moala.

This example visually highlights the active cell without using conditional formatting when the keyboard arrow keys are used to move around the sheet:

Dim strCol As String Dim iCol As Integer Dim dblRow As Double

Sub HighlightRight()

HighLight 0, 1 End Sub

Sub HighlightLeft() HighLight 0, -1 End Sub

Sub HighlightUp()

Sub HighlightDown()

HighLight 1, 0, 1 End Sub

Sub HighLight(dblxRow As Double, iyCol As Integer, Optional dblZ As Double = 0) On Error GoTo NoGo strCol = Mid(ActiveCell.Offset(dblxRow, iyCol).Address, _

InStr(ActiveCell.Offset(dblxRow, iyCol).Address, "$") + 1, _ InStr(2, ActiveCell.Offset(dblxRow, iyCol).Address, "$") - 2) iCol = ActiveCell.Column dblRow = ActiveCell.Row

Application.ScreenUpdating = False

With Range(strCol & ":" & strCol & "," & dblRow + dblZ & ":" & dblRow + dblZ) .Select

Application.ScreenUpdating = True .Item(dblRow + dblxRow).Activate End With

NoGo: End Sub

Sub DisableDelete()

Cells(ActiveCell.Row, ActiveCell.Column).Select Application.OnKey "{DEL}" End Sub

Sub ReSet()

Application.OnKey "{RIGHT}"

Application.OnKey "{LEFT}"

Application.OnKey "{UP}"

Application.OnKey "{DOWN}" End Sub

0 0

Post a comment