views:

982

answers:

2

My app needs to build a buffer from all the selected cells on a worksheet. I have it working correctly when the selected cells are all one contiguous group, but if the user selects a group of cells, then holds down the control key and selects other cells that are not contiguous to the first set of cells, the Worksheet's Selected range only gives me information on that first group of cells.

I tried the Range "Next" property, but walking that seems to just return ranges containing cell-by-cell traversal of that first range.

+1  A: 

The Address property returns selected ranges (separated by comma)

When I select B4 to D10 and then H9 to 016 (by holding ctrl), Selection.Address returns $B$4:$D$10,$H$9:$O$16.

shahkalpesh
+3  A: 

VBA Code

for i = 1 to selection.Areas.Count : debug.Print selection.areas(i).Address : next

shahkalpesh