G
Greg Maxey
Does anyone know how Range.Calculate manages to define the "range" of a
selection of cells to just those cells and exclude adjacent cells?
I created a simple 3 column x 2 row table and put the number 2 in each cell.
Then I selected the middle column and ran this code:
Sub Test()
Dim oCell As Word.Cell
Dim i As Single
MsgBox Selection.Range.Calculate
MsgBox Selection.Range.Cells.Count 'Returns 4 as unfortunately is expected.
For Each oCell In Selection.Range.Cells
On Error Resume Next
i = i + CSng(Left(oCell.Range.Text, Len(oCell.Range.Text) - 2))
Next oCell
MsgBox i 'Again returns 8 as unfortunately expected.
End Sub
It is the same range, but somehow Range.Calculate knows to process only the
values that are actually selected, and not the entire selection range. How
does it do this?
Thanks
selection of cells to just those cells and exclude adjacent cells?
I created a simple 3 column x 2 row table and put the number 2 in each cell.
Then I selected the middle column and ran this code:
Sub Test()
Dim oCell As Word.Cell
Dim i As Single
MsgBox Selection.Range.Calculate
MsgBox Selection.Range.Cells.Count 'Returns 4 as unfortunately is expected.
For Each oCell In Selection.Range.Cells
On Error Resume Next
i = i + CSng(Left(oCell.Range.Text, Len(oCell.Range.Text) - 2))
Next oCell
MsgBox i 'Again returns 8 as unfortunately expected.
End Sub
It is the same range, but somehow Range.Calculate knows to process only the
values that are actually selected, and not the entire selection range. How
does it do this?
Thanks