VBA

How to add order in a column of a table

Sub Order()
Dim Str As String

For Each obj In ActiveDocument.Tables
  oCell = obj.Cell(2, 1)
  On Error GoTo errorhandler
  oText1 = oCell.Text
  If oText1 = Null Then
    GoTo errorhandler
  End If
  Length = Len(oText1) - 2
  oText = Mid(oText1, 1, Length)
  If oText = "Selection" Then
    MsgBox "find it!"
    For i = 1 To obj.Rows.Count - 1
      j = i + 1
      Str = obj.Cell(j, 5).Range.Text
      obj.Cell(i + 1, 5).Range.Text = Str & "  " & i
    Next
  End If
errorhandler:
Next
End Sub

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章