Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default multi cells selected

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default multi cells selected

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default multi cells selected

But you still could get the address of each cell in the selection:

Dim myCell as range
for each mycell in selection.cells
msgbox mycell.address(0,0)
next mycell

and you can check with this kind of code.

if selection.cells.count 1 then
'multiple cells selected
end if

if selection.areas.count 1 then
'multiple areas selected
end if

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


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple cells or columns are selected instead of selected cell or Mikey Excel Discussion (Misc queries) 1 April 29th 09 09:48 PM
Cells are selected but aren't displayed as selected Nifty Excel Discussion (Misc queries) 2 September 17th 06 07:22 PM
Cells are selected but aren't displayed as selected Nifty Excel Worksheet Functions 0 September 17th 06 11:34 AM
Last list item selected in a Multi-Select list box? Brian Excel Programming 3 December 5th 05 09:12 PM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"