- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-12-5
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-15 10:44 ½s¿è
¦^´_ 13# ã´£³¡ªL
ÁÂÁ«e½ú«ü¾É,«á¾Ç¦b¦¹©«¾Ç¨ì«Ü¦hª¾ÃÑ
½Ð«e½ú¦A«ü¾É,ÁÂÁÂ
¨ç¼Æ¿é¤J:
µ²ªG:
Function GetNum(xS As String, X$, TY$)
'¡ô¦Ûq¨ç¼Æ¦WGetNum,ÅܼÆ1(xS)¬O¦r¦ê,ÅܼÆ2(X)¬O¦r¦ê,ÅܼÆ3(TY)¬O¦r¦ê
Dim T, k, s%, xD
'¡ô«Å§i(T,k,xD)¬O³q¥Î«¬ÅܼÆ,(s)¬Oµu¾ã¼Æ
'«á¾ÇÁÙ¤£¯à½T©w%&¦p¦ó¥¿½T¨Ï¥Î,¥i¯à¬O¨¾¤î·¸¦ì??
GetNum = ""
'¡ô¥OGetNum³o¦Ûq¨ç¼ÆȬOªÅ¦r¤¸!
'¥Nªíªº¬O¥ý¤£ºÞ«á±¯à¤£¯à¦³È,¥ýµ¹ªÅ®æ
xS = Replace(xS, X, "|" & X)
'¡ô¥OxS³o¿é¤JªºÅܼƦr¦ê¶i¦æ¦r¤¸¸m´«(¥Î¿é¤JªºXÅܼƦr¦ê´«¦¨ "|"²Å¸¹³s±µXÅܼƦr¦ê)
s = Len(X)
'¡ô¥Os³oµu¾ã¼ÆÅܼƬO ¿é¤JªºXÅܼƦr¦êªº¦r¤¸¼Æ
If s = 0 Then Exit Function
'¡ô¦pªGs¦r¤¸¼Æ¬O 0,´Nµ²§ô¦Ûq¨ç¼Æ
Set xD = CreateObject("Scripting.Dictionary")
'¡ô¥OxD¬O ¦r¨å
For Each T In Split(xS & "|", "|")
'¡ô³]¶¶°j°é!¥OT¬O (xS¿é¤JªºÅܼƦr¦ê³s±µ"|"²Å¸¹«á ³Q"|"²Å¸¹¤À³Îªº¤@ºû°}¦C)°}¦C¤l¦r¦ê
'& "|" ¼È¤£²M·¡¬°¦ón¥[³oÓ??Àµ½Ð«ü¾É
If Left(T, s) = X Then
'¡ô¦pªG°j°é°}¦C¤l¦r¦êTªº¥ª°¼ s(¿é¤JªºXÅܼƦr¦êªº¦r¤¸¼Æ) ªº¦r¦ê,¬O ¿é¤JªºXÅܼƦr¦ê??
k = k + 1
'¡ô¥Ok³o³q¥Î«¬ÅܼÆ+1
xD(k) = Val(Mid(T, s + 1))
'¡ô¥OK³o¼Æ¦r¬Okey,
'ITEM¬O °j°é°}¦C¤l¦r¦êT ¨ú±qs + 1Ó¦r¤¸¶}©lªº¥þ³¡¦r¤¸,¸gVal¨ç¦¡Âà¤Æªº¼ÆÈ
'¾Ç¨ì¤F
'1.xD(k) = Val(Mid(T, 1)),Val¨ç¦¡Âà¤Æªº¦r¦ê¶}ÀYY¤£¬O¼Æ¦r,¦^¶ÇȬ°0
'2.Val¨ç¦¡Âà¤Æªº¦r¦ê§PŪ¨ì ¥iÂà¤Æ¬°¼ÆȳsÄò¦r¤¸,¤§«áªº¦r¤¸±Ë±ó
End If
Next
If k = 0 Then Exit Function
'¡ô¦pªGk¬O 0,´Nµ²§ô¦Ûq¨ç¼Æ
If UCase(TY) = "MAX" Then
'¡ô¦pªG¨ç¼Æ¿é¤JªºTYÅܼƦr¦ê¬O "MAX" ??
GetNum = Application.Max(xD.Items)
'¡ô¥OGetNum¦^¶ÇxD¦r¨å¸Ìªºitems³Ì¤jÈ
ElseIf UCase(TY) = "MIN" Then
'¡ô§_«h¦pªG¨ç¼Æ¿é¤JªºTYÅܼƦr¦ê¬O "MIN" ??
GetNum = Application.Min(xD.Items)
'¡ô¥OGetNum¦^¶ÇxD¦r¨å¸Ìªºitems³Ì¤pÈ
ElseIf UCase(TY) = "SUM" Then
'¡ô¦A§_«h¦pªG¨ç¼Æ¿é¤JªºTYÅܼƦr¦ê¬O "SUM" ??
GetNum = Application.Sum(xD.Items)
'¡ô¥OGetNum¦^¶ÇxD¦r¨å¸Ìªºitems¥§¡È
End If
End Function
http://forum.twbts.com/thread-23804-1-1.html
'¤WÃìµ²©«¥Î Application.Volatile ¬O¦]¬°®æ¦¡ÅܤƷ|¼vÅT¦Ûq¨ç¼Æ,
'©Ò¥H±N¨Ï¥ÎªÌ©w¸qªº¨ç¼Æ¼Ð¥Ü¬°©öÅÜ,
'´ú¸Õµ²ªG¬O´å¼Ð®æÅܤƴN·|«ºâ¦Ûq¨ç¼Æ
'¦¹©«¥i¥H¤£¥²¨Ï¥ÎApplication.Volatile,¥Ø¼Ð®æ½s¿è´N·|¦^¶ÇȧY¥i
Sub T_20221215()
MsgBox Val("4.21¡B03/04 12:00 AA-173.25(x)")
End Sub |
|