- ©«¤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-3
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-12-14 08:07 ½s¿è
¦^´_ 7# ranceymm
ÁÂÁ«e½ú¦^´_
¤µ¤Ñ¦AÀ˵ø&½Æ²ß¤F¦¹©«,µo²{«Ü¦hªº¦h¾l»P¤£¨¬,«á¾Ç¤]¦A¾Ç²ß¤¤,¥ý¨D¦³,¦A¨D¦n,¤ß±oµù¸Ñ¨Ñ°Ñ¦Ò
Option Explicit
Function ³Ì¤jÈ(«e¦r¤¸ As String, «á¦r¤¸ As String, Àx¦s®æ As Range) As Double
'¡ô³Ì¤jÈ()¬O¦Û¤v©w¸qªº¨ç¼Æ¦W¦r,¸Ì±ªº:
'«e¦r¤¸ As String :«e¦r¤¸«Å§i¬O¦r¦êÅܼÆ,¬O¨Ï¥Î¦¹¨ç¼Æ»Ý¿é¤JªºÈ "ªø"
'«á¦r¤¸ As String :«á¦r¤¸¤]«Å§i¬O¦r¦êÅܼÆ,¬O¨Ï¥Î¦¹¨ç¼Æ»Ý¿é¤JªºÈ "¡B"
'Àx¦s®æ As Range :Àx¦s®æ«Å§i¬OÀx¦s®æÅܼÆ,¦Ó¥B¬O¨Ï¥Î¦¹¨ç¼Æ»Ý¿é¤J(©Î¥Î¿ïªº)ªºÀx¦s®æ¦ì§}
'As Double¬O«Å§i³o³Ì¤jȵ²ªG¬OÂùºë«×¤p¼Æ
'¦pªGn¤@¥y¸Ü±Ôz:µ¹³o¨ç¼Æ¨âÓ¦r¦ê,¤@Ó³æ®æªºÀx¦s®æ¦ì§},«á±ªºµ{§Ç¦^¶Ç Âùºë«×È,
'¦Ü©ó¦^¶Çªº¬O¤£¬O³Ì¤jÈ?? ´Nn¬Ý¦¨¬O¦³¨S¦³§ì¨ì³Ì¤jÈ
'«nªº¬O«e½ú¹ï¸ê®ÆªºÅÞ¿è³W«h¬O§_¥¿½T! ¸ê®Æ¿ù»~´Nºâ¤£¥X¨Ó!¦³¦nªº¶}©l,¦¨¥\´N¤£»·¤F
Dim Y, V, A$, j&, P#
'¡ô«Å§iÅܼÆ:(Y,V)¬O³q¥Î«¬ÅܼÆ,(A)¬O¦r¦êÅܼÆ,(j)¬Oªø¾ã¼ÆÅܼÆ,(P)¬OÂùºë«×¤p¼Æ
Application.Volatile
'¡ô±N¨Ï¥ÎªÌ©w¸qªº¨ç¼Æ¼Ð¥Ü¬°©öÅÜ¡C
'https://learn.microsoft.com/zh-tw/office/vba/api/excel.application.volatile
Set Y = CreateObject("Scripting.Dictionary")
'¡ô¥OY¬O¦r¨å
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/dictionary-object
A = Replace(Replace(Replace(Àx¦s®æ, " " & «e¦r¤¸, ","), «á¦r¤¸, ","), " ", ",")
'¡ô¥OA³o¦r¦êÅܼƬO ¨ç¼Æ¨Ï¥Î®É¿é¤J D3 Àx¦s®æ¸ÌªºÈ,¸g¹L¤T¦¸¸m´«¦r¤¸ (" ªø":",")("¡B":",")(" ":",")
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/replace-function
V = Split(A, ",")
'¡ô¥OV³o³q¥Î«¬ÅܼƸˤJ A¦r¦ê³QSplit()¤À³Î¦¨ªº¼ÆÓ¦r¦ê,V´NÅܦ¨¬O¤@ºû°}¦C
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/split-function
For j = 3 To UBound(V) Step 4
'¡ô³]¶¶°j°é!j±q3¨ìV°}¦Cªº³Ì«á¤@Ó¯Á¤Þ¸¹½X,j°j°é¨C¶¦^¨Ó¤@¦¸´N¥[3,7,11,.....
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/fornext-statement
If IsNumeric(V(j)) And V(j) <> "" Then
'¡ô¦pªG¯Á¤ÞÈj¦ì¸mªºV°}¦Cȸg¹LIsNumeric()¨ç¼Æ§PÂ_¬O¼Æ¦r,¦Ó¥B¤£¬OªÅ¦r¤¸ ??
'https://learn.microsoft.com/zh-tw/office/vba/language/reference/user-interface-help/isnumeric-function
P = V(j): Y(P) = ""
'¡ô·íIF±ø¥ó¦¨¥ß!´N¥OP³oÂùºë«×ÅܼƸˤJ ¯Á¤ÞÈj¦ì¸mªºV°}¦CÈ
'µM«á±N³oPÅܼƷíkey,item¬OªÅ¦r¤¸,ˤJY¦r¨å¸Ì
End If
Next
³Ì¤jÈ = Application.Max(Y.keys())
'¡ô¥O ³Ì¤jÈ ³oÂùºë«×ÅܼƥΠMax() ¨ú±oY¦r¨å¸ÌKEYSªº³Ì¤jÈ,Åã¥Ü¦bÀx¦s®æ¸Ì
'https://learn.microsoft.com/zh-tw/office/vba/api/excel.worksheetfunction.max
End Function |
|