Prev: Lookup Macro
Next: Detect SharePoint Lock
From: Poli on 15 Apr 2010 17:04 Using MS Word 2007 and Window's XP I had this macro written into one of my programs and it will lookup fields and replace the MAX, or Min Value. I need to convert it into Word. Can someone help me? Thank you. I have another post that also reads "Lookup Macro but forgot that I had this other program where I had already done this I just don't know how to convert it into Word. GLOBAL varMAX_A GLOBAL varMIN_A Sub GetMinMaxValueA() Dim EntryFlag As Boolean EntryFlag = False varMAX_A = 0 varMIN_A = 9999.99 If Application.activeform.Fields("LBSIN_A").contents <> 0 Then If Application.activeform.Fields("LBSIN_A").contents > varMAX_A Then varMAX_A = Application.activeform.Fields("LBSIN_A").contents End If If Application.activeform.Fields("LBSIN_A").contents < varMIN_A Then varMIN_A = Application.activeform.Fields("LBSIN_A").contents End If EntryFlag = True End If
From: Doug Robbins - Word MVP on 15 Apr 2010 17:23 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 "Poli" <Poli(a)discussions.microsoft.com> wrote in message news:7382F4D0-6D6A-44A9-8238-237B6151319D(a)microsoft.com... > 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! > >
|
Pages: 1 Prev: Lookup Macro Next: Detect SharePoint Lock |