Lookup Macro

P

Poli

Using Microsoft Word 2007 on Window's XP
I need a Macro that will:
Lookup number fields, and return a minimum, value and put that value into
another field.
I will also need to do a Maximum and Average lookup.
Can you please help me with this?
My fields are
FHZ_A thru FHZ_T, 20 fields that have calculations
When I enter into these fields I want field "TotMinA" to lookup those fields
and return a the smallest minimum value into field "TotMinA"

I will also need a macro that will lookup these fields and give me the
Maximum value into another field and the Average Value into another field.

If you can help me with one I might be able to figure out the other two.


Thank you so much!
 
D

Doug Robbins - Word MVP

Try

Dim ffname As String
Dim i As Long
Dim ffarray As Variant
Dim ffsum As Variant
ReDim ffarray(20)
With ActiveDocument
For i = 0 To 19
ffname = "FHZ_" & Chr(65 + i)
ffarray(i + 1) = .FormFields(ffname).result
ffsum = ffsum + .FormFields(ffname).result
Next i
End With
WordBasic.SortArray ffarray
MsgBox "The Minimum Value is " & ffarray(1)
MsgBox "The Maximum Value is " & ffarray(20)
MsgBox "The Average is " & ffsum / 20


--
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, originally posted via msnews.microsoft.com
 

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