Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50068

Deselect selection if it's not within a defined range

$
0
0
I have a defined range of cells (C1:C10) that I would like the user to select. But, if the user selects any other cell outside the defined range, I would like to de-select that cell and select cell C1. If the user's selection is within C1:C10, then I should leave the user's selection as it is. Here is what I have so far, but I am getting an error:

Code:

Private Sub Workbook_SheetSelectionChange (ByVal Sh As Object, ByVal Target As Range)
    If Not Target.Select = Range("C1:C10") Then
        Range("C1").Select
    End If
End Sub


Viewing all articles
Browse latest Browse all 50068

Trending Articles