LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.sdk
external usenet poster
 
Posts: 1
Default Iterating through an Excel Range with COM automation

aloha!

I'm trapping the WorksheetChange and WorksheetSelectionChange events with
some C++ COM code and would like to properly iterate through the cells in
the range object. Single cell or single block ranges are no problems, but I
can't seem to detect/process cases where the range is discontinuous (as one
encounters when ctrl-clicking various cells).

In VBA, one can obviously use something like "for each cellObj in rangeObj".
With COM, however, one is limited to using an object's properties/method;
the desired results aren't readily available through the Cells or Index
properties.

On the surface it seems simple enough: check the "Count" property, then use
Index(n) to access the individual cells. But a funny thing happens: Index(2)
and onwards return cells that are not necessarily selected (ie. in the
range). For example: if you select six cells in a diagonal
(A2,B3,C4,D5,E6,F7), the results of Index(n) would be: (A2,A3,A4,A5,A6,A7).
Ditto, I believe for Cells(n). And so this is a row offset parameter to the
first cell of the range only and not at all useful.

Am I missing something or has anyone experienced this?

Best regards,

Stephen


 
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
Automation of change of data range KIOhio Charts and Charting in Excel 4 June 30th 09 04:55 AM
iterating checkboxes [email protected] Excel Discussion (Misc queries) 1 May 11th 05 08:42 PM
variable range automation Ryan Proudfit Charts and Charting in Excel 1 March 31st 05 01:46 AM
Iterating through Cells .Net/Excel 2003 R Kalal Excel Programming 6 February 20th 04 01:13 AM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


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

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

About Us

"It's about Microsoft Excel"