![]() |
|
|
|
#1
|
|||
|
|||
|
No, but it is late here and I have certainly been reading to much vba help to make much sense tonight. Here is the code I have in the document. I may pick this up again tomorrow. Cheers to you - Until tomorrow?
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, j As Long, k As Long, l As Long
With ActiveDocument.Tables(2)
If ContentControl.Range.InRange(.Range) Then
For i = 2 To .Rows.Count - 1
With .Cell(i, 2).Range.ContentControls(1)
If .Range.Text <> .PlaceholderText Then
k = k + 1
For j = 1 To .DropdownListEntries.Count
If .DropdownListEntries(j) = .Range.Text Then
l = l + .DropdownListEntries(j).Value
Exit For
End If
Next
End If
End With
Next
With .Rows.Last.Cells(2).Range
If k > 0 Then
.Text = Format(l / k, "0.00")
Else
.Text = vbNullString
End If
End With
End If
End With
End Sub
|
|
| Tags |
| content controls, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Move to next content control
|
cksm4 | Word VBA | 13 | 07-02-2019 07:48 PM |
Deleting a table from a content control -- preserving the content control
|
BrainSlugs83 | Word Tables | 8 | 11-14-2013 03:06 AM |
Content control problem
|
Anja | Word | 2 | 10-16-2013 09:56 AM |
Hierarchical content control
|
ntjson | Word VBA | 1 | 04-04-2013 12:07 AM |
Content control titles
|
jillapass | Word VBA | 3 | 05-29-2012 06:11 AM |