ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

VBA & WorkSheetFunction.min ½Õ¥X°}¦C·¥¤p­È

VBA & WorkSheetFunction.min ½Õ¥X°}¦C·¥¤p­È

Dim ary(1 To 4) As Integer
    ary(1) = 10
    ary(2) = 15
    ary(3) = 9
    ary(4) = 11
   
    Debug.Print WorksheetFunction.Min(Array(ary(2), ary(4)))
   ¥Øªº: ½Õ¥X °}¦C 2~ 4 ¤¤, ªº³Ì¤p­È
    ¤W­±¬O¿ù»~ªºµ{¦¡½X,  ¥u¬O¦^¶Ç 11 , ¦Ó«D ¥¿½T­È 9
    µ{¦¡½XÁöµM¥i¥H§ï¦¨ Debug.Print WorksheetFunction.Min(Array(ary(2), ary(3), ary(4)))
    ¦ý«oµLªk¾A¦X©ó¤j«¬°}¦C¤¤.
    ¬O§_¦³¨ä¥Lªº¼gªk, ½Õ¤¤¤@ºû°}¦C¤¤, ¬Y¤@°Ï¬qªº·¥¤p­È ?

¦^´_ 6# GBKEE

     ·PÁ±zªá®É¶¡¦^ÂСA·P®¦¡ã

TOP

¦^´_ 5# alumi
¦Û­q¨ç¼Æ
  1. Option Explicit
  2. Sub Ex()
  3.     Dim xi As Integer, Ary(1 To 10) As Integer
  4.     For xi = 1 To 10
  5.         Ary(xi) = Int(100 * Rnd)       '¶Ã¼Æ  
  6.     Next
  7.     MsgBox °Ï¶¡­È("Min", Ary, 5, 10)  ' Ary(5):Ary(10) ªº°Ï¶¡
  8. End Sub
  9. Function °Ï¶¡­È(Max_Or_Min As String, °}¦C As Variant, °Ï¶¡1 As Integer, °Ï¶¡2 As Integer) As Long
  10.    Dim xi As Integer, AR()
  11.    ReDim AR(°Ï¶¡1 To °Ï¶¡2)      '½Æ»sAry(5):Ary(10) ªº°Ï¶¡ªº°}¦C¤¸¯À¼Æ
  12.    For xi = °Ï¶¡1 To °Ï¶¡2
  13.         AR(xi) = °}¦C(xi)
  14.     Next
  15.     If UCase(Max_Or_Min) = "MAX" Then
  16.         °Ï¶¡­È = WorksheetFunction.Max(AR)
  17.     Else
  18.         °Ï¶¡­È = WorksheetFunction.Min(AR)
  19.     End If
  20. End Function
½Æ»s¥N½X

TOP

¦^´_ 3# stillfish00


    ±zªºª½Ä±¤èªk¡A¨S¦³°ÝÃD¡D
¡@­ì¥ý¬O¦b·Q¡A­Y¦³²{¦¨ªº¨ç¼Æ¥i¥Hª½±µ®³¨Ó¥Î¡A¾ã­ÓVBA µ{¦¡¡A·|¬Ý°_¨Ó¤ñºë²¡D

TOP

¦^´_  alumi
¤W­±¬O¿ù»~ªºµ{¦¡½X,  ¥u¬O¦^¶Ç 11 , ¦Ó«D ¥¿½T­È 9
¨S¦³¿ù°Ú !
Debug.Print WorksheetFu ...
GBKEE µoªí©ó 2012-10-27 07:05


    ¨ä¹ê±z»¡ªº¨S¿ù.
    ¥u¬O³æ¯Â¦a·Q§â ¤@¨Ç Excel ¥\¯à, ª½±µ ®M¤J VBA ¨Ó¨Ï¥Î.
   ¨Ò¦p:   
   debug.print WorkSheetFunction.Min(range(cells(5,"A") , cells(100, "A")))     ' ¶Ç¦^ Cells (5 ~ 100 ,"A") ªº³Ì¤p­È
   debug.print WorkSheetFunction.Min(ary) ' ÁöµM·|¶Ç¦^ °}¦C¤¤ªº³Ì¤p­È, ¬O§_ ¯à°÷«ü©w °}¦C¤¤ "¬Y¤@°Ï¶¡" ªº³Ì¤p­È

   ·PÁ±zªº¦^ÂÐ.

TOP

Debug.Print WorksheetFunction.Min(Array(ary(2), ary(4)))
   ¥Øªº: ½Õ¥X °}¦C 2~ 4 ¤¤, ªº³Ì¤p­È   
...
alumi µoªí©ó 2012-10-27 00:40

³Ìª½Ä±ªº¤èªk...
  1.     Dim i, minValue As Integer
  2.     minValue = ary(2)
  3.     For i = 2 To 4
  4.         If ary(i) < minValue Then minValue = ary(i)
  5.     Next i
½Æ»s¥N½X

TOP

¦^´_ 1# alumi
¤W­±¬O¿ù»~ªºµ{¦¡½X,  ¥u¬O¦^¶Ç 11 , ¦Ó«D ¥¿½T­È 9
¨S¦³¿ù°Ú !
Debug.Print WorksheetFunction.Min(Array(ary(2), ary(4)))
ary(2)=15   ary(4)=11   ¨º¦³ 9.
¸Õ¸Õ  Debug.Print WorksheetFunction.Min(ary))

TOP

        ÀR«ä¦Û¦b : ­ì½Ì§O¤H´N¬Oµ½«Ý¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD