G
Greg Maxey
Posted below are a few methods for stripping the end of cell marker from a
cell range. Realizing that in these simple examples speed is not an issue,
but I was wondering if anyone could offer any technical insight into which
method if any of these would be considered "best practice." Would be
interested in other methods anyone might be using as well.
Sub Test1()
Dim oRng As Range
Set oRng = ActiveDocument.Tables(1).Cell(1, 1).Range
oRng.MoveEnd wdCharacter, -1
MsgBox oRng.Text
End Sub
Sub Test2()
Dim oStr As String
oStr = ActiveDocument.Tables(1).Cell(1, 1).Range.Text
MsgBox Left(oStr, Len(oStr) - 2)
End Sub
Sub Test3()
Dim oRng As Range
Set oRng = ActiveDocument.Tables(1).Cell(1, 1).Range
oRng.End = oRng.End - 1
MsgBox oRng.Text
End Sub
Sub Test4()
Dim oString As String
oStr = ActiveDocument.Tables(1).Cell(1, 1).Range.Text
MsgBox Replace(oStr, ChrW(13) & ChrW(7), "")
End Sub
cell range. Realizing that in these simple examples speed is not an issue,
but I was wondering if anyone could offer any technical insight into which
method if any of these would be considered "best practice." Would be
interested in other methods anyone might be using as well.
Sub Test1()
Dim oRng As Range
Set oRng = ActiveDocument.Tables(1).Cell(1, 1).Range
oRng.MoveEnd wdCharacter, -1
MsgBox oRng.Text
End Sub
Sub Test2()
Dim oStr As String
oStr = ActiveDocument.Tables(1).Cell(1, 1).Range.Text
MsgBox Left(oStr, Len(oStr) - 2)
End Sub
Sub Test3()
Dim oRng As Range
Set oRng = ActiveDocument.Tables(1).Cell(1, 1).Range
oRng.End = oRng.End - 1
MsgBox oRng.Text
End Sub
Sub Test4()
Dim oString As String
oStr = ActiveDocument.Tables(1).Cell(1, 1).Range.Text
MsgBox Replace(oStr, ChrW(13) & ChrW(7), "")
End Sub