PDA

View Full Version : Solved: Select the cell with the click of a mouse, and have the result of calculation



marreco
08-02-2012, 04:22 PM
Hi.
I need to have the option to choose the cell with the click of a mouse, and have the result of calculation in the cell where the mouse clicked
Private Sub Worksheet_Calculate()
Soma = 0
Coluna = 1

Do While Cells(Coluna, 1) <> ""
Soma = Soma + Cells(Coluna, 1)
Coluna = Coluna + 1
Loop

Cells(1, 3) = Soma 'Here I would like the return was where I choose in Excel

End SubCross-Post
http://www.excelforum.com/excel-programming-vba-macros/849598-select-the-cell-with-the-click-of-a-mouse-and-have-the-result-of-calculation.html

Bob Phillips
08-03-2012, 01:15 AM
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Soma = 0
Coluna = 1

Do While Cells(Coluna, 1) <> ""
Soma = Soma + Cells(Coluna, 1)
Coluna = Coluna + 1
Loop

Target.Value = Soma
End Sub

marreco
08-03-2012, 03:23 AM
Hi.

It was great, thank you very much!!