Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
selection.cells(1).value
Hello,
I am working with the selection object. If I select a single cell. my selection.Cells.Count = 1. I can do this and get the correct value of the cell: selection.cells(1).value However I can also do this: selection.cells(0).value and get the value of the cell above the selected. Is this correct? Why is this happening? Seems a little scary? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
selection.cells(1).value
Line 1 and 2 are equivalent
selection.cells(1).value cells(rowoffset:=1,columnoffset:=0) so what you are saying is Range("A1").cells.count = Range("A2").cells.count = 1 "greg" wrote: Hello, I am working with the selection object. If I select a single cell. my selection.Cells.Count = 1. I can do this and get the correct value of the cell: selection.cells(1).value However I can also do this: selection.cells(0).value and get the value of the cell above the selected. Is this correct? Why is this happening? Seems a little scary? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
selection.cells(1).value
Although it is interesting that you can read beyond the boundaries of the
range object it is not exactly a fatal flaw. The reason that this is happening is that a range object is essentially just a pointer to the first cell with a reference to the number of cells that encompass the range. If you offset from the pointer outside of the valid range of the object then you get into cells that are not part of the range object. Very similar to C/C++ programming where you can read or write beyond the boundaries of an array or such. -- HTH... Jim Thomlinson "greg" wrote: Hello, I am working with the selection object. If I select a single cell. my selection.Cells.Count = 1. I can do this and get the correct value of the cell: selection.cells(1).value However I can also do this: selection.cells(0).value and get the value of the cell above the selected. Is this correct? Why is this happening? Seems a little scary? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy Selection - Paste Selection - Delete Selection | Excel Programming | |||
Copy Selection - Transpose Selection - Delete Selection | Excel Discussion (Misc queries) | |||
Get a range of cells from a selection of cells | Excel Programming | |||
Macro to select cells and then new selection from selected cells | Excel Programming | |||
Skip cells with TAB/SHIFT+TAB but allow arrow keys/mouse selection of skipped cells | Excel Programming |