![]() |
|
|||||||
|
|
Thread Tools | Display Modes |
|
#2
|
|||
|
|||
|
Assumes the column containing the Low, Med, High is column 2:
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oTbl As Word.Table
Dim oCol As New Collection
Dim lngIndex As Long
Dim oRng As Word.Range
Dim oRow As Row
Dim lngCell As Long
Set oTbl = ActiveDocument.Tables(1)
For Each oRow In oTbl.Rows
If Left(oRow.Cells(2).Range.Text, Len(oRow.Cells(2).Range.Text) - 2) = "High" Then
oCol.Add oRow
End If
Next oRow
Set oRng = ActiveDocument.Bookmarks("bmRows").Range
If oRng.Tables.Count = 1 Then
oRng.Tables(1).Delete
End If
Set oTbl = oRng.Tables.Add(oRng, oCol.Count, 3)
For lngIndex = 1 To oCol.Count
For lngCell = 1 To oCol(lngIndex).Range.Cells.Count
oTbl.Rows(lngIndex).Cells(lngCell).Range.Text = Left(oCol(lngIndex).Cells(lngCell).Range.Text, _
Len(oCol(lngIndex).Cells(lngCell).Range.Text) - 2)
Next
Next
ActiveDocument.Bookmarks.Add "bmRows", oTbl.Range
End Sub
|
| Tags |
| bookmark, rows, table |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Mouseover cell to indicate mouse pointer location based on Specific Row/Column values | bolandk | Excel | 1 | 05-15-2014 08:22 AM |
| Group Table Rows/Column (like Excel Group) | eoinymc | Word | 1 | 03-11-2014 04:51 AM |
Need help on duplicates in column; deciding which to keep based on other column
|
nwcf | Excel | 3 | 01-31-2014 09:43 AM |
Grouping table rows to prevent individual rows from breaking across pages
|
dennist77 | Word | 1 | 10-29-2013 11:39 PM |
Referencing a Image File and Location
|
matt8445 | PowerPoint | 2 | 11-08-2012 08:23 AM |