#1
|
|||
|
|||
Simplest way to get row and column number?
Is there a simpler way to get row and column numbers from the current selected cell in a word table with horizontally or vertically merged cells?
I need to retrieve the text of the cell above current selected cell. This code does not works (works only if I add 1 to column index) cause there's merged cells in the selected row. Code:
selection.tables(1).Cell(selection.Cells(1).rowindex-1,selection.Cells(1).columnindex).Range.text
__________________
Backup your original file before doing any modification. |
#2
|
||||
|
||||
For current cell addresses, look in the 'Sticky' thread at the top of this forum...
Finding the adjacent cell(s) requires looping forward/backward, as appropriate. With horizontally merged cells, there may be more than one cell above or below. With vertically merged cells, you may have to loop through multiple rows to find all those adjacent or to find the one below. And, where you're dealing with both, you might have to deal with horizontally-merged cells above/below/beside vertical ones.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Apparently it will be too complex, I give up, as it will not be something essential.
Thanks!
__________________
Backup your original file before doing any modification. |
#4
|
||||
|
||||
If you use the selection object it isn't too complex.
Code:
Sub GetUp() Dim aCell As Cell, aRng As Range Set aRng = Selection.Range Selection.Range.Cells(1).Select Selection.MoveUp If Selection.Range.Cells.Count = 1 Then Debug.Print Selection.Range.Cells(1).Range.Text Else Debug.Print "No cells immediately above selection" End If aRng.Select 'restore selection End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#5
|
|||
|
|||
Works fine.
Many thanks.
__________________
Backup your original file before doing any modification. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Count number of Ms between Hs in a column | Marcia | Excel | 6 | 05-12-2020 06:21 PM |
Want a quotient using a constant to show up in column c each time a number is added to column b | fibbermcghee | Excel | 2 | 12-09-2014 05:48 PM |
Formatting numbers in number column | MS baby | Project | 1 | 06-03-2014 02:43 PM |
What's The Best & Simplest Software Program To Backing Up Outlook 2010 | highbids | Outlook | 1 | 08-23-2010 04:10 PM |
Last Number in a Column | paulrm906 | Excel | 1 | 12-05-2008 07:51 PM |