I would like to select individual, non-adjacent cells by mouse-click and use those cells as the range to be used within a macro. At the end of the calculation, I would like the result to appear in the status bar.
Currently, I can use the macro when the range consists of adjacent cells selected by either clicking and dragging the mouse or using shift+mouse-click. As one can do on the worksheet itself, I have tried to use ctrl+mouse-click to select non-adjacent cells, but receive an error message. I move around that by including "On Error Resume Next," but the cells selected using the control key are not included in the calculation.
How might I go about selecting non-adjacent cells to be used as the range?
Thank you.
For reference, the current code reads:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Application.StatusBar = "ESum: " & _
Application.Evaluate("=10*Log(Sum(10^(0.1*(" & Target.Address & "))))")
End Sub
Currently, I can use the macro when the range consists of adjacent cells selected by either clicking and dragging the mouse or using shift+mouse-click. As one can do on the worksheet itself, I have tried to use ctrl+mouse-click to select non-adjacent cells, but receive an error message. I move around that by including "On Error Resume Next," but the cells selected using the control key are not included in the calculation.
How might I go about selecting non-adjacent cells to be used as the range?
Thank you.
For reference, the current code reads:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Application.StatusBar = "ESum: " & _
Application.Evaluate("=10*Log(Sum(10^(0.1*(" & Target.Address & "))))")
End Sub