View Single Post
 
Old 06-26-2020, 03:47 PM
Logit Logit is offline Windows 10 Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

.
This is one of many methods :

In the Sheet Module paste :

Code:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   TestInRange
End Sub

In a Regular Module paste :

Code:
Option Explicit

Function InRange(Range1 As Range, Range2 As Range) As Boolean
' returns True if Range1 is within Range2
Dim InterSectRange As Range
    Set InterSectRange = Application.Intersect(Range1, Range2)
    InRange = Not InterSectRange Is Nothing
    Set InterSectRange = Nothing
End Function

Sub TestInRange()
    If InRange(ActiveCell, Range("H6:H81")) Then
        ' code to handle that the active cell is within the right range
        ActiveCell.Offset(0, 1).Value = ""
    Else
        Exit Sub
    End If
End Sub
Reply With Quote