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

[µo°Ý] ¦p¦ó¨Ï¥Î¥¨¶°¦Û°Ê­pºâªÑ»ùº¦¶^°±»ù?

¦^´_ 3# shuasa
À³¥Î jackyq  ¤j¤jªº¨ç¦¡µy¥[­×§ï¦p¤U¡A
°Ñ¦Ò¤@¤U¡G
  1. Public Function UpDown(ud As Range, Optional UpDn As Boolean = True)
  2.     If ud.Value = 0 Then UpDown = 0: Exit Function
  3.       
  4.     Price_Sample = Array(0, 10, 50, 100, 500, 1000)
  5.     interval_Sample = Array(0.01, 0.05, 0.1, 0.5, 1, 5)
  6.          
  7.     interval = Application.WorksheetFunction.Lookup(ud.Value * IIf(UpDn, 1.1, 0.9), Price_Sample, interval_Sample)
  8.     UpDown = Application.WorksheetFunction.Floor(ud.Value * IIf(UpDn, 1.1, 0.9), interval)
  9. End Function
½Æ»s¥N½X
º¦°±»ù¨ç¦¡
=UpDown(F8)
µ¥©ó
=UpDown(F8,1)
µ¥©ó
=UpDown(F8,True)

¶^°±»ù¨ç¦¡
=UpDown(F8,0)
µ¥©ó
=UpDown(F8,False)

TOP

¦^´_ 3# shuasa
¥ç¥iª½±µ¥H VBA µ{¦¡¬q¨Ó³B²z¡G
  1. Sub Ex()
  2.     Dim xVal As Double
  3.    
  4.     xVal = UpDown([F8])
  5.     MsgBox "UpDown([F8]) (º¦°±»ù) = " & xVal
  6.     xVal = UpDown([F8], 1)
  7.     MsgBox "UpDown([F8], 1) (º¦°±»ù) = " & xVal
  8.     xVal = UpDown([F8], True)
  9.     MsgBox "UpDown([F8], True) (º¦°±»ù) = " & xVal
  10.    
  11.     xVal = UpDown([F8], 0)
  12.     MsgBox "UpDown([F8], 0) (¶^°±»ù) = " & xVal
  13.     xVal = UpDown([F8], False)
  14.     MsgBox "UpDown([F8], False) (¶^°±»ù) = " & xVal
  15. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# shuasa
¨S¯d·N¨ì Ceiling ªº¤½¦¡¡G
­×¥¿¦p¤U
  1. Public Function UpDown(ud As Range, Optional UpDn As Boolean = True)
  2.     If ud.Value = 0 Then UpDown = 0: Exit Function
  3.       
  4.     Price_Sample = Array(0, 10, 50, 100, 500, 1000)
  5.     interval_Sample = Array(0.01, 0.05, 0.1, 0.5, 1, 5)
  6.          
  7.     interval = Application.WorksheetFunction.Lookup(ud.Value * IIf(UpDn, 1.1, 0.9), Price_Sample, interval_Sample)
  8.    
  9.     If UpDn Then
  10.         UpDown = Application.WorksheetFunction.Floor(ud.Value * 1.1, interval)
  11.     Else
  12.         UpDown = Application.WorksheetFunction.Ceiling(ud.Value * 0.9, interval)
  13.     End If
  14. End Function
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : §Ú­Ì­n°µ¦nªÀ·|ªºÀô«O¡A¤]­n°µ¦n¤º¤ßªºÀô«O¡C
ªð¦^¦Cªí ¤W¤@¥DÃD