G
Greg Maxey
Masters,
Earlier I posted a response in the Tables NG. The OP was asking how to
right a macro to add 4 to the value in column A and put the result in column
B. The OP was looking for a macro to avoid entering repetitive formulas in
his table. I came up with the following which seems to work, but I am
wondering if it is efficient and the correct approach. Thanks:
Sub ScratchMacro()
Dim i As Long
Dim aValue As Range
Dim bValue As Range
Dim oTbl As Table
Set oTbl = Selection.Tables(1)
For i = 1 To oTbl.Rows.Count
Set aValue = oTbl.Cell(i, 1).Range
If IsNumeric(aValue) Then
With aValue
.MoveEnd Unit:=wdCharacter, Count:=-1
End With
Set bValue = oTbl.Cell(i, 2).Range
bValue = aValue + 4
End If
Next
End Sub
Earlier I posted a response in the Tables NG. The OP was asking how to
right a macro to add 4 to the value in column A and put the result in column
B. The OP was looking for a macro to avoid entering repetitive formulas in
his table. I came up with the following which seems to work, but I am
wondering if it is efficient and the correct approach. Thanks:
Sub ScratchMacro()
Dim i As Long
Dim aValue As Range
Dim bValue As Range
Dim oTbl As Table
Set oTbl = Selection.Tables(1)
For i = 1 To oTbl.Rows.Count
Set aValue = oTbl.Cell(i, 1).Range
If IsNumeric(aValue) Then
With aValue
.MoveEnd Unit:=wdCharacter, Count:=-1
End With
Set bValue = oTbl.Cell(i, 2).Range
bValue = aValue + 4
End If
Next
End Sub