Microsoft Office Tutorials and References
In Depth Information
Tables: Copying Formulas
' * * * * *¶
Function UpdateFormula(ByVal newFormula As String, _¶
rw As Long) As String¶
'Variable declaration¶
Dim rowChange As Long¶
Dim i As Long¶
Dim nrToChange As String¶
Dim posStart As Long¶
'Difference between original and new row index¶
rowChange = rw - startRow¶
'Check each character in the formula¶
For i = 1 To Len(newFormula)¶
posStart = i¶
'whether it's numeric¶
'accumulate the numerals to get¶
'complete number¶
Do While IsNumeric(Mid(newFormula, i, 1))¶
nrToChange = nrToChange & (Mid(newFormula, i, 1))¶
i = i + 1¶
Loop¶
'If there's a number¶
If Len(nrToChange) > 0 Then¶
'increment that number and replace the original¶
newFormula = Mid(newFormula, 1, posStart - 1) _¶
& CStr(CLng(nrToChange) + rowChange) _¶
& Mid(newFormula, i)¶
End If¶
nrToChange = ""¶
Next¶
UpdateFormula = newFormula¶
End Function¶
' * * * * *¶
Function SelectionIsValid(sel As Word.Selection) As Boolean¶
SelectionIsValid = False¶
If sel.Information(wdWithInTable) Then¶
If Selection.Cells(1).Range.Fields.Count >= 1 Then¶
If Selection.Cells(1).Range.Fields(1).Type _¶
= wdFieldExpression Then¶
SelectionIsValid = True¶
End If¶
End If¶
End If¶
End Function¶
Wrd
Search JabSto ::




Custom Search