Range describes a group of non-adjacent cells

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.

Answers


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.


VBA Code

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


Need Your Help

writing to text file does not alway work/save

c# filewriter

i have this code that compares two text files and write the difference to a log file but for some reason the log.txt file is some times blank even when is test with some lines starting with a * the...

How to make a Wordpress post only visible for the author and through a direct link?

wordpress wordpress-plugin posts author

I want to make a Wordpress site where users can register them self. They only need the ability to update there profile and write a post. This post should be only visible to the author or through a ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.