Right click and iterate through selection
I want to drag a selection box around a group of cells in one column
(a5..a10) for example and then when the right-click is pressed give the user the option to click "Process" and then iterate through each cell entry in the range. How do I do that? I 've got a fair idea for the right-click thing but I'm not sure how to step through each cell in the range and process the numbers. Thanks for any help Paul |
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 |
All times are GMT +1. The time now is 01:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com