LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Test if cells are selected

I have a VSTO Excel app where I need to test each row in a range to
see whether the user has selected the cell in column D in that row,
and carry out an operation if they have.

But I'm getting some very erratic results. I tried using For Each
cell as Cell in ActiveWorksheet.Selection.Cells, but that didn't
work. So I went to this:

Dim _col As Integer
Dim _row As Integer
For cellCount As Integer = 0 To .Application.Selection.cells.count -
1
_col = .Application.Selection.cells(cellCount).Column
_row = .Application.Selection.cells(cellCount).Row + 1

The "+ 1" on the row makes no sense to me, but it was off by a row if
I didn't do that.

The problem is, when I select multiple cells in column D, I get weird
results. Two contiguous ones works fine. But if I pick four
contiguous ones, it only sees the first and third. Actually, it
depends on the order in which I select them. And if they aren't
contiguous, it gets even weirder.

Is there a simpler way to do this? A way where instead of going
through the selection and testing the cells to see if they're in the
right column, I can go down that column and check to see if each cell
is selected? I haven't been able to find a Selected or IsSelected
property on cells.

Thanks,
Lisa

 
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
Test to see if selected range is single row? davegb Excel Programming 6 March 19th 07 09:18 PM
Cells are selected but aren't displayed as selected Nifty Excel Worksheet Functions 0 September 17th 06 11:34 AM
Macro to take selected cells times a selected cell Craig Excel Programming 4 October 24th 05 12:54 AM
How can I test when any worksheet within a workbook is selected Peter McNaughton Excel Programming 2 January 29th 04 04:59 AM


All times are GMT +1. The time now is 10:14 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"