View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
greg greg is offline
external usenet poster
 
Posts: 108
Default multi cells selected

thanks!
that worked

"Leith Ross" wrote in message
...
On Feb 28, 1:54 pm, "greg" wrote:
Can I tell if multi cells are selected? And can I get each cell?
So if i
click A1
Ctrl+click D1
Ctrl+click G1

Can I get each of these cells?
thanks


Hello Greg,

The Range object has an Areas collection property. If you select a
single cell or a contiguous range of cells then Areas.Count = 1. Here
is a code snippet to display what Ranges you have selected in message
box.

Sub ShowRanges()

Dim Msg As String
Dim Rng As Range

For Each Rng In Selection.Areas
Msg = Msg & Rng.Address & vbCrLf
Next Rng

MsgBox "You selected the following ranges..." & vbCrLf & Msg

End Sub

Sincerely,
Leith Ross