View Single Post
 
Old 05-21-2014, 07:31 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,428
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote