View Single Post
 
Old 09-16-2018, 10:47 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For what you've attached, all you need for the macro is:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Dim i As Long, r As Long, c As Long, StrOLF As String
With CCtrl
  If .Title = "MyCC_MAF" Then
    For i = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(i).Text = .Range.Text Then
        StrOLF = .DropdownListEntries(i).Value
        Exit For
      End If
    Next
    With .Range.Cells(1)
      r = .RowIndex
      c = .ColumnIndex
    End With
    With .Range.Tables(1)
      .Cell(r, c + 1).Range.Text = StrOLF
      .Cell(r, c + 2).Range.Text = Format(StrOLF * CCtrl.Range.Text, "0.0")
    End With
  End If
End With
ActiveDocument.Fields.Update
End Sub
You don't need a content control for OLF or a field for MAF+OLF. Since the latter is referenced in subsequent formulae, though, you can get the same result by replacing:
{=B6/MyMAF \# "0.00" }
with:
{=B6/SUM(MyTotalReq D2) \# "0.00"}
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote