View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_363_] Leith Ross[_363_] is offline
external usenet poster
 
Posts: 1
Default Right click and iterate through selection


Hello Paul,

Here is a code example that sums the values of the cells selected when
the user Right Clicks the selection. The sum of the Selected cells is
placed below the last cell in the selection.

Remember that setting Cnacel to True in this event will disable the
context menus.

EXAMPLE:


Code:
--------------------
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)

Dim Cell
Dim N

Cancel = True

For Each Cell In Selection
N = N + Cell.Value
Next Cell

Selection.Cells(1, 1).End(xlDown).Value = N

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=492446