Sub GetAvg()
Dim cellLoop As Cell, CellContents, datePreviousVisit, intColumnIndex As Integer
intColumnIndex = Selection.Cells(1).ColumnIndex
Selection.GoTo wdGoToBookmark, , , "VitalSigns"
Selection.MoveDown wdLine, 1
Selection.HomeKey wdLine
Selection.MoveRight wdWord, 5, wdExtend
If IsDate(Selection.Range.Text) Then
datePreviousVisit = InputBox("Enter Fill date:", , CDate(Selection.Range.Text))
Else
datePreviousVisit = InputBox("Enter Fill date:")
End If
If Len(datePreviousVisit & "") = 0 Then Exit Sub Else datePreviousVisit = CDate(datePreviousVisit)
'Debug.Print Format(datePreviousVisit, "mmm dd, yyyy")
For Each cellLoop In ActiveDocument.Tables(3).Columns(intColumnIndex).Cells
CellContents = Split(Left(cellLoop.Range.Text, Len(cellLoop.Range.Text) - 2), ",")
If UBound(CellContents) = 1 Then
cellLoop.Range.Text = Trim(CellContents(0))
If CellContents(1) = "" Then CellContents(1) = 0
cellLoop.Range.Text = Trim(CellContents(0)) & ", " & Trim(CellContents(1)) & ", " & Trim(Round((cellLoop.Range.Calculate - CellContents(1)) / DateDiff("d", datePreviousVisit, ActiveDocument.Bookmarks("DOS").Range.Text), 1))
End If
Next cellLoop
ActiveDocument.Tables(3).Cell(1, intColumnIndex).Select
End Sub
with the missing gridline, I get this error message: "run time error 5992; Cannot access individual columns in this collection because the table has mixed cell widths."Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.