Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multiple cells or columns are selected instead of selected cell or | Excel Discussion (Misc queries) | |||
Test to see if selected range is single row? | Excel Programming | |||
Cells are selected but aren't displayed as selected | Excel Worksheet Functions | |||
Macro to take selected cells times a selected cell | Excel Programming | |||
How can I test when any worksheet within a workbook is selected | Excel Programming |