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

·s¤âµo°Ý (Function)

·s¤âµo°Ý (Function)

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-2-16 07:37 ½s¿è

·Q½Ð°Ý¦U¦ì¤j¤j´X­Ó¦³ÃöFunctionªºµ{§Ç

1.§Úª¾¹DFunctionµ{§Ç¯à¶Ç¦^­È
¥i¬O§Ú¤£À´ªº¬O¶Ç¦^­È¬O¤°»ò·N«ä
¬O¦b°õ¦æ§¹«á·|±N­ÈÅã¥Ü¥X¨Ó¶Ü?

¥i¬O³o­Ó¥\¯à¤£¬O¨Ï¥ÎSubµ{§Ç´N¯à²£¥Íªº¶Ü?
¬O§Ú¦³»~·|¤°»ò¶Ü?

2.¥t¥~Functionµ{§Ç¯à¦b¤£«Å§iÅܼƪºª¬ªp¤U
¨Ï¥ÎÅܼƶÜ?

3.¤U¦Cµ{¦¡¬O¯àÅã¥Ü°T®§10
Function GetData()
           GetData = 10
End Function
Sub Msg()
           MsgBox  GetData
End Sub

¥i¬O¤U¦Cµ{¦¡«o¥u¯àÅã¥ÜªÅ¥Õ
Function GetData()
           GetData = "¤j®a¦n"
End Function
Sub Msg()
           MsgBox GetData
End Sub
³o¤S¬O¬°¤°»ò©O??

¥H¤W
¦A³Â·Ð¤j®a¤F

1. vba¦Û©wfunction¸òexcel¤ºµ{ªºfunction e.g.: sum(), count() ¯S©Ê¬Û­Y

3. À³¸Ó¬O§A¹q¸£³]©w°ÝÃD¡A§Úªº¯à¥¿±`Åã¥Ü¥X¡u¤j®a¦n¡v
§A¥i±N·í¤¤ªº¤¤¤å§ï¦¨­^¤å¦A¸Õ¸Õ¬Ý

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-2-16 07:40 ½s¿è

¦^´_ 1# tainanfriend
  1. Option Explicit
  2. Function AA()
  3.     AA = "IS ok"
  4. End Function
  5. Function Ex(A As Range, B As Range)
  6.     Ex = A + B
  7. End Function
  8. Sub Test()
  9.     Dim A  As Integer
  10.     MsgBox AA
  11.     A = Ex(Range("D2"), Range("D3"))
  12.     If A > 10 Then MsgBox A
  13. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦pÆp¥Û¡j®É¶¡¹ï¤@­Ó¦³´¼¼zªº¤H¦Ó¨¥¡A´N¦pÆp¥Û¯ë¬Ã¶Q¡F¦ý¹ï·M¤H¨Ó»¡¡A«o¹³¬O¤@§âªd¤g¡A¤@ÂI»ù­È¤]¨S¦³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD