Results 1 to 2 of 2

Thread: Contextually referencing the table cell / row a MacroButton field is located in

  1. #1

    Contextually referencing the table cell / row a MacroButton field is located in

    Prefacing that I am a VBA novice. I have a (Word) table which has a number of MacroButton fields assigned to cells in the first column of each row (image of dummy example as below):

    The macros I wish to execute on clicking the MacroButton fields (specifically, to move the row in question up / down, or to clear that row's contents) requires a means of referencing or selecting the row that the cell these MacroButton fields are present in.

    I've done a bit of surface level searching but can't seem to get a straight answer as to how to define:
    - firstly, the cell of the MacroButton field I have clicked (my assumption is that clicking the field will make the cell it is located in 'active' / 'selected'; additionally, I currently have the macro associated with the field to trigger on a single click rather than a double click);
    - and then subsequently, reference the row that said cell is part of.

    Any help would be appreciated. If there is a more elegant way to use a content control to perform the same checks, I'm open to such an option as well. (Conversely I am not too keen on using an ActiveX control or a form field.)

    At this stage I don't think I require assistance for the coding of the actual macros to move / clear the rows; there are topics here on VBAExpress and elsewhere that I am referencing to achieve these, and if need be I can make another topic for further assistance.

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Sep 2005
    The following in the called macro will return the row reference:

    MsgBox Selection.Cells(1).RowIndex

    Visit my website:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts