ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   adding (https://www.excelbanter.com/excel-discussion-misc-queries/121676-adding.html)

A.S.

adding
 
is there any formula that let's you sum all the numbers before the number you
select?

for example,
Col 1 Col 2
1 5
2 2
3 9
.....

so if the number 9 is chosen then it adds 9+2+5 or if 2 is chosen then it
adds 2+5. Keeping in mind that there are X numbers so the list could have
1600 numbers.

thanks.

Bob Phillips

adding
 
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
On Error Resume Next
MsgBox Application.Sum(Range(Cells(1, .Column), Target))
On Error GoTo 0
End With
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click



--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
"A.S." wrote in message
...
is there any formula that let's you sum all the numbers before the number
you
select?

for example,
Col 1 Col 2
1 5
2 2
3 9
....

so if the number 9 is chosen then it adds 9+2+5 or if 2 is chosen then it
adds 2+5. Keeping in mind that there are X numbers so the list could have
1600 numbers.

thanks.





All times are GMT +1. The time now is 06:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com