Consulting

Results 1 to 3 of 3

Thread: Solved: Select the cell with the click of a mouse, and have the result of calculation

  1. #1
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location

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

    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
    [VBA]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 Sub[/VBA]Cross-Post
    http://www.excelforum.com/excel-prog...lculation.html

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]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 [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Tutor
    Joined
    Jan 2011
    Posts
    272
    Location
    Hi.

    It was great, thank you very much!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •