View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
andreashermle andreashermle is offline
external usenet poster
 
Posts: 123
Default MsgBox with information on selected cells

On Dec 18, 12:49*pm, "Peter T" <peter_t@discussions wrote:
Yet another way, to cater for possibility of a multi area selection

Sub test()
Dim i As Long
Dim sMsg
Dim rng As Range

* * Set rng = Selection

* * With rng.Areas(1)
* * * * sMsg = .Count & " cell(s) *" & .Address(0, 0)
* * End With
* * For i = 2 To rng.Areas.Count
* * * * With rng.Areas(i)
* * * * * * sMsg = sMsg & vbCr & .Count & " cell(s) *" & ..Address(0, 0)
* * * * End With
* * Next

* * MsgBox sMsg

End Sub

Regards,
Peter T

"andreashermle" wrote in message

...



Dear Experts:


I would like to have a macro that shows me ...


the number of selected cells in a column (contiguous range) and ...
the cell reference of the upper most cell selected.


Example: Range selected: A2:A13 (only selections in one column, no
selections spanning 2 or more columns)


The macro is to inform in a MsgBox as follows:


12 cells selected, starting in A2


Help is much appreciated. Thank you very much in advance.


Regards, Andreas- Hide quoted text -


- Show quoted text -


Dear Peter,

very nice VBA solution. Great help. Thank you very much. Regards,
Andreas