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."
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
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE