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

[µo°Ý] ¦Û©w¸q¨ç¼Æ¦p¦ó½á­Èµ¹Àx¦s®æ

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-5-24 15:26 ½s¿è

¦^´_ 10# dou10801


    ÁÂÁ«e½ú¦A¦^´_
«á¾Ç¬ã¨s¦p¤U¤è®×,½Ð«e½ú°Ñ¦Ò

°õ¦æµ²ªG:



Option Explicit
Function MyCustomFunction(ByVal arg1 As String, ByVal arg2 As String) As String
Evaluate "test1(" & Application.Caller.Offset(-1, -1).Address(0, 0) & ",""" & arg1 & """,""" & arg2 & """)"
MyCustomFunction = ""
End Function

Sub test1(c As Range, a As String, b As String)
c = a & b
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 10# dou10801


    ½Ð«e½ú°Ñ¦Ò³o©«:
http://forum.twbts.com/viewthrea ... %B9%AA%BA%B0%DD%C3D
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ dou10801 ©ó 2023-5-25 11:48 ½s¿è

¦^´_ 4# Andy2483
¦^ÂÐ 5# quickfixer
©µ¦ù¾Ç²ß,¬O§_¥i±N[¶Ç»¼°Ñ¼Æ],¶Ç¦Ü[¨ä¥L¤u§@ªí],·P®¦.
§ù¤p¥­

TOP

¦^´_ 13# dou10801


    ÁÂÁ«e½úÄ~Äò¤@°_¾Ç²ß
«á¾Ç¬ã²ß«e½úªº»Ý¨D±¡¹Ò,¾Ç²ß¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò

Option Explicit
Function MyCustomFunction(ByVal arg1 As String, ByVal arg2 As String) As String
Evaluate "test1(¤u§@ªí1!A1,""" & arg1 & """,""" & arg2 & """)"
MyCustomFunction = ""
End Function
Function test1(c As Range, a As String, b As String)
c = a & b
End Function
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 14# Andy2483
·P®¦«ü¾É,¤W¤F¤@½Ò[°Ñ¼Æ¶Ç»¼],ÁÂÁÂ.
§ù¤p¥­

TOP

Function MyCustomFunction(arg1, arg2, V%) '¦Û­q¨ç¼Æ¥uµ¹µ²ªG­È, ¤£¯à«ü©w¦s©ñ¦ì¸m   
Dim result
If V = 1 Then result = Val(arg1) + Val(arg2)
If V = 2 Then result = arg1 & arg2
MyCustomFunction = result
End Function

Sub TEST() 'µ¹¦Û­q¨ç¼Æ[°Ñ¼Æ],¦A«ü©w¶ñ¤J¦ì¸m, ¶·«ö¶s°õ¦æ
Sheets("¤u§@ªí2").[B2] = MyCustomFunction(100, 200, 1)
Sheets("¤u§@ªí2").[B3] = MyCustomFunction("§Úªº¦Û­q", "¨ç¼Æ", 2)
End Sub

TOP

¦^´_ 16# ­ã´£³¡ªL


    ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É

«á¾ÇÂǦ¹©«¾Ç²ß«e½úªº¤è®×,¤è®×¾Ç²ß¤ß±o¦p¤U,½Ð«e½ú¦A«ü¾É

°õ¦æµ²ªG:



Option Explicit
Function MyCustomFunction(arg1, arg2, V%) '¦Û­q¨ç¼Æ¥uµ¹µ²ªG­È, ¤£¯à«ü©w¦s©ñ¦ì¸m
'¡ô¦Û­q¨ç¼ÆMyCustomFunction(),(arg1,arg2)«Å§i¬°³q¥Î«¬ÅܼÆ,V¬Oµu¾ã¼Æ
Dim result
'¡ô«Å§iÅܼÆ:result¬O³q¥Î«¬ÅܼÆ
If V = 1 Then result = Val(arg1) + Val(arg2)
'¡ô¦pªGVÅܼƬO 1,´N¥OresultÅܼƬO ¨âÅܼƦUÂର¼Æ­È«á¬Û¥[­È
If V = 2 Then result = arg1 & arg2
'¡ô¦pªGVÅܼƬO 2,´N¥OresultÅܼƬO ¨âÅܼƬ۳s±µ«áªº·s¦r¦ê
MyCustomFunction = result
'¡ô¥OMyCustomFunction¨ç¼Æ¦^¶Ç resultÅܼƭÈ
End Function

Sub TEST() 'µ¹¦Û­q¨ç¼Æ[°Ñ¼Æ],¦A«ü©w¶ñ¤J¦ì¸m, ¶·«ö¶s°õ¦æ
Sheets("¤u§@ªí2").[B2] = MyCustomFunction(100, 200, 1)
'¡ô¥Oªí2.[B2]Àx¦s®æ­È¬O ¥Harg1=100,arg2=200,V=1,
'µ¹MyCustomFunction()¨ç¼Æ¦^¶Ç­È

Sheets("¤u§@ªí2").[B3] = MyCustomFunction("§Úªº¦Û­q", "¨ç¼Æ", 2)
'¡ô¥Oªí2.[B3]Àx¦s®æ­È¬O ¥Harg1="§Úªº¦Û­q",arg2="¨ç¼Æ",V=1,
'µ¹MyCustomFunction()¨ç¼Æ¦^¶Ç­È

End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¦^´_ 16# ­ã´£³¡ªL
·P®¦,¦h¤@ºØ¾Ç²ß¤è¦¡.
§ù¤p¥­

TOP

        ÀR«ä¦Û¦b : ÀR§¤±`®¦¤v¹L¡B¶¢½Í²ö½×¤H«D¡C
ªð¦^¦Cªí ¤W¤@¥DÃD