How do you get VBA in Word to select the rows under the cursors' current position in a table? Ideally, select only the rows with text in the first column.
How do you get VBA in Word to select the rows under the cursors' current position in a table? Ideally, select only the rows with text in the first column.
You can select the next row with text in column 1 line this:
Your not going to be able to select non-contiguous rows.Sub ScratchMacro() 'A basic Word macro coded by Greg Maxey, http://gregmaxey.com/word_tips.html, 7/11/2017 Dim oRow As Row, oThisROw As Row Dim oTbl As Table Dim lngIndex As Long Set oTbl = Selection.Tables(1) Set oThisROw = Selection.Rows(1) For lngIndex = oThisROw.Index + 1 To oTbl.Rows.Count Set oRow = oTbl.Rows(lngIndex) If Len(oRow.Cells(1).Range.Text) > 2 Then oRow.Select Exit For End If Next lbl_Exit: Exit Sub End Sub
This code did not work. I got a "Can't execute code in break mode" at line Set oTbl = Selection.Tables(1). To bring things down to my level, perhaps just knowing how to select the next 2+ rows under the current position of the cursor would work. Thank you for your help thus far.