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

[µo°Ý] EXCEL VBA ¥Ñ­pºâ»¡©ú­pºâª÷ÃB(¤G)

[µo°Ý] EXCEL VBA ¥Ñ­pºâ»¡©ú­pºâª÷ÃB(¤G)

­ìµo°Ý¦p¤U¡A¬O§Q¥Î§R°£¦r¦ê¨Ó§R°£³¡¥²­nªº¦r¤¸
http://forum.twbts.com/thread-7705-1-1.html

¦]¬°«e¤è¦¡ÁÙ¤£¬O«Ü¤è«K¨Ï¥Î¡A§Æ±æ³]©w²³æ³W«h¨Ó§R°£¤£¥²­nªº¦r¤¸©Î¬O«O¯d¥²­nªº¦r¤¸
CÄæ­pºâ»¡©ú¤¤¡A¥u­n«O¯d ¼Æ¦r 0-9¡A¹Bºâ²Å¸¹ + - * / ^ % ¡A¬A¸¹ ( ), ­^¤å a-z A-Z ¨ä¥L§R°£¡A
§R°£«á·|Åܦ¨¼Ð·Ç­pºâ¦¡¡A¦A­pºâ¦¡©ñ¤JDÄæª÷ÃBÄæ¡A¬°¤F¤è«KÀˬd¥¿½T©Ê¡A¥i§_¥H¤½¦¡¤è¦¡©ñ¤J¡C




ÀÉ®× EXCEL VBA ­pºâ»¡©úÂàª÷ÃB(¤G).rar (5.99 KB)
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

¦^´_ 1# ML089
  1. Function MyCal(Mystr$) As Double
  2. Application.Volatile
  3. Set d = CreateObject("Scripting.Dictionary")
  4. ar = Array(40, 41, 42, 43, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 60, 61, 62, 91, 92, 93, 94, 95)
  5. For i = 0 To UBound(ar)
  6. d(Chr(ar(i))) = Chr(ar(i))
  7. Next
  8. For i = Len(Mystr) To 1 Step -1
  9. Mystr = Replace(Mystr, Mid(Mystr, i, 1), d(Mid(Mystr, i, 1)))
  10. Next
  11. MyCal = Evaluate(Mystr)
  12. End Function
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 2# Hsieh
·PÁ¦^ÂСA
³o¦¸¦³ CreateObject("Scripting.Dictionary") Åý§Ú¤@ª½¬Ý¤£À´¡A¤Wºô¬ã¨s«á¤j­P¤w¸gÀ´¤F§Aªºµ{¦¡¡A
¦]¬°­n­×§ï¥h°£ªº½X¡A­«·s¨Ì·Ó§Aªº¤½¦¡ºc¬[½s¼g¦p¤U:

¥t¥~¦A¸É¥R½Ð±Ð¤@°ÝÃD¡A Mid(¦r¦ê, i, 1) ¨ú¥X¤@¦r¦p¦ó§P©w¬O¤¤¤å¦r?

Function MyCal(MyStr$) As Double
    Application.Volatile
    Set d = CreateObject("Scripting.Dictionary")
    Dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.0123456789%+-*/^()"
    For i = 1 To Len(Dic)
        d(Mid(Dic, i, 1)) = Mid(Dic, i, 1)
    Next
    For i = Len(MyStr) To 1 Step -1
        MyStr = Replace(MyStr, Mid(MyStr, i, 1), d(Mid(MyStr, i, 1)))
    Next
    MyCal = Evaluate(MyStr)
End Function
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¦^´_ 3# ML089
§PÂ_¬O§_¬°º~¦r¡A¥i§Q¥ÎASC¨ç¼Æ¨ú±o¦r¤¸½X¡A¤p©ó0«h¬°º~¦r
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 4# Hsieh

·PÁ¦^ÂÐ

¦bEXCEL¬O¥ÎCODE¡Aº¸¥B½X¬O¥¿¼Æ5¦ì
¦bVBA¬O¥ÎASC¡Aº¸¥B½X¬O­t¼Æ5¦ì
VBAªºASC»PEXCELªºASC¬O¤£¦P·N¸q¡A
EXCELªº¨ç¼Æ»PVBAªº¨ç¼Æ¤£¦P¦W¥Îªk¤]¤£¦P¡A¾Ç²ß°_¨Ó¯u¬Oµh­W¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

EXCEL VBA ­pºâ»¡©úÂàª÷ÃB(¤G).rar (7.58 KB)
1

µû¤À¤H¼Æ

    • Hsieh: µ¹§A¤@­ÓÆg!ª÷¿ú + 2

TOP

¦^´_ 6# chin15
«z! ¨Ï¥Î CreateObject("VBSCRIPT.REGEXP") Åýµ{¦¡½X§óµu¡A¯u¼F®`
ÁöµM¬Ý¤£À´¡AÁÙ¬O¥ýµ¹¤@­ÓÆg
EXCEL¸Ì§ä¤£¨ì»¡©ú¡Aºô¸ô³£¬O¨Ò¤l§ä¤£¨ì§¹¾ã»¡©ú¡A¤£ª¾­þ¸Ì¦³»¡©ú¥i¥H¬Ý¡A¥i§_§iª¾ ¤@¤U¡C
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

http://www.dotblogs.com.tw/yc421206/archive/2008/12/14/6386.aspx

TOP

¦^´_ 1# ML089
´£¨Ñ§A°Ñ¦Ò¡C
  1. Function decodeFMT(decode As String) As String
  2.     Dim tLen%, txt$, num$
  3.    
  4.     If Len(decode) = 0 Then decodeFMT = "": Exit Function
  5.     num = "=Sum("
  6.     For tLen = 1 To Len(decode)
  7.            txt = Mid(decode, tLen, 1)
  8.            If txt = "(" Or txt = ")" Or txt = "+" Or txt = "+" Or txt = "+" Or txt = "-" Or txt = "*" Or txt = "/" Or (txt >= "0" And txt <= "9") Then
  9.                 num = num + txt
  10.            End If
  11.     Next tLen
  12.     decodeFMT = num + ")"
  13. End Function
½Æ»s¥N½X
EXCEL VBA ­pºâ»¡©úÂàª÷ÃB.rar (9.07 KB)

TOP

¦^´_ 8# chin15

»¡©ú²M·¡¡A·PÁ§A¡A¤SÅý§Ú¦h¾Ç¤F¦n´X©Û¡A¦Aµ¹§A¤@­Ó Æg
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

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