none
How to get the row or column number in a selection of multiple rows? RRS feed

  • Question

  • Hi all,

    I'm trying to write codes to delete multiple non-consecutive rows or columns. 

    But my problem is:

    For example, when I select some non-consecutive rows or columns,  how can I get row or column numbers in the selection so I can use each number as an index to specify which row or column to delete?

    Thanks in advance!

    Please let me know if i didn't make it clear. 

    Regards,

    CNL

    Wednesday, May 24, 2017 4:00 AM

Answers

  • Hello,

    I think it is impossible to return non-consecutive rows/columns index in Selection.

    Word provides Selection.Rows property  and Selection.Columns property to get the collection in selection. However, when we select non-consecutive rows/columns, for example, select 2nd column of a table and press Ctrl and select 4th column, Word recognizes i am selecting 4th column, there is one column in the selection.columns collection, so i could only get index "4" in the selection.columns

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CNL777 Friday, May 26, 2017 7:47 AM
    Thursday, May 25, 2017 5:41 AM
    Moderator

All replies

  • You shouldn't need to select anything. Simply tell Word which rows/columns you want to delete. When deleting multiple rows/columns, work backwards - that way you don't have to keep track of changing index #s as preceding rows/columns are deleted.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, May 25, 2017 12:07 AM
  • Hi Paul,

    What if a table has many rows / columns? 

    How can I tell the row/ column number quickly?

    What I want is:

    Say, look through a table and if there are unnecessary rows/columns, non-consecutive may be, select them and have them deleted. 

    But, I have difficulty in telling Word which rows /columns the selection contains. 

    Thanks!

    Regards,

    CNL

    Thursday, May 25, 2017 5:18 AM
  • Hello,

    I think it is impossible to return non-consecutive rows/columns index in Selection.

    Word provides Selection.Rows property  and Selection.Columns property to get the collection in selection. However, when we select non-consecutive rows/columns, for example, select 2nd column of a table and press Ctrl and select 4th column, Word recognizes i am selecting 4th column, there is one column in the selection.columns collection, so i could only get index "4" in the selection.columns

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CNL777 Friday, May 26, 2017 7:47 AM
    Thursday, May 25, 2017 5:41 AM
    Moderator
  • What characteristics designate the rows/columns as unnecessary?

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Thursday, May 25, 2017 10:40 AM