-
1
- #1
Some worksheet events expose [tt]Target As Range[/tt] argument to check processed range before executing the rest of code. In one of my old workbooks I had, to first check if one or more cells were selected:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
[pre]If Target.Cells.Count = 1 Then
...
End If
End Sub[/pre]
By accident I right-clicked 'Select all' button, and got 'overflow' runtime error in reply. Cells.Count returns Long value, with upper limit below worksheet size.
[tt]Target.Cells.CountLarge[/tt] removes this error. CountLarge returns Variant type value. What was strange for me, in Excel 2016, 32 bit, Locals window, I can see proper number of cells (17179869184) with type Variant/<Unsupported variant type>.
combo
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
[pre]If Target.Cells.Count = 1 Then
...
End If
End Sub[/pre]
By accident I right-clicked 'Select all' button, and got 'overflow' runtime error in reply. Cells.Count returns Long value, with upper limit below worksheet size.
[tt]Target.Cells.CountLarge[/tt] removes this error. CountLarge returns Variant type value. What was strange for me, in Excel 2016, 32 bit, Locals window, I can see proper number of cells (17179869184) with type Variant/<Unsupported variant type>.
combo