Automatic response in Word, based on entered data?

P

Priscilla

I have a table in my document that has 3 columns of data, 2 are entered by
the user, and the third column will be automatically filled, based on what
was entered in the first 2. For example if the data was "rare" and
"insignificant" in the first and second column, then the third column should
return "LOW"
 
D

Doug Robbins - Word MVP

To do this in a Word document, you should insert DropDown formfields in each
row of the first two columns and insert the data items that the user can
select from into those formfields. Then on exit from the each of those
formfields, you would run a macro that gets the DropDown.Value of each of
the DropDown formfields and then use a Select Case construction to return a
value to be entered into a TextBox formfield that you have in the third
column

The code to run on exit from each of the DropDown formfields would be
something like:

Dim col1 As Long, col2 As Long, col3 As Long
Dim consequence As String
With Selection.Rows(1)
col1 = .Cells(1).Range.FormFields(1).DropDown.Value
col2 = .Cells(2).Range.FormFields(2).DropDown.Value
col3 = col1 * col2
Select Case col3
Case 1
consequence = "Low"
Case 2
consequence = "Moderate"
Case 3
consequence = "High"
Case 4
consequence = "Severe"
Case 5
consequence = "Catastrophic"
Case Else
consequence = "The end of the world is nigh"
End Select
.Cells(3).Range.FormFields(1).Result = consequence
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top