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

[µo°Ý] ¦Û°Ê©¹«e»¼¸É±Æµ{§Ç¸¹

[µo°Ý] ¦Û°Ê©¹«e»¼¸É±Æµ{§Ç¸¹

½Ð±Ð¦U¦ì ¦p¦ó©¹«e»¼¸É±Æµ{§Ç¸¹

»Ý¨D¥Ü·N:


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

¥»©«³Ì«á¥Ñ shuo1125 ©ó 2023-6-30 23:29 ½s¿è

¦^´_ 1# Andy2483
Andy¤j¦n!
µ{«×¦³­­..¶È¯à°w¹ï¤£¦P¶µ¥Ø½s§Ç,¬Ý¦³µL¨ä¥L°ª¤â¥X¤â!
Sub TEST()
    Dim wSht As Worksheet, R&, i&, T$, N&
    Set wSht = Sheets("¤u§@ªí1")
        R = wSht.Cells(wSht.Rows.Count, "D").End(3).Row
            For i = 2 To R
                If wSht.Cells(i, 4).Value <> T Then
                T = wSht.Cells(i, 4).Value
                N = 1
            End If
                wSht.Cells(i, 5).Value = N
                N = N + 1
            Next i
End Sub

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2023-7-4 07:33 ½s¿è

¦^´_ 2# shuo1125


    ÁÂÁ«e½ú
¤è®×±¡¹Ò²¤¦³¤£¦P,·¥¨ã±¡¹Ò»Ý¨DªÌ°Ñ¦Ò»ù­È,¤è®×°õ¦æµ²ªG¦p¤U:

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

TOP

Sub TEST_1()
Dim xR As Range, T$(2), S$(2), N%
For Each xR In Range([a2], [a65536].End(3))
    T(1) = xR: T(2) = xR(1, 2)
    If T(1) <> S(1) Then S(1) = T(1): S(2) = "\\": N = 0
    N = N - (T(2) <> S(2))
    S(2) = T(2)
    xR(1, 3) = N
Next
End Sub

Sub TEST_2()
Dim xR As Range, T$, TT$, S$, SS$, N%
For Each xR In Range([a2], [a65536].End(3))
    T = xR: TT = T & "\" & xR(1, 2)
    N = N * -(T = S) - (TT <> SS)
    S = T: SS = TT
    xR(1, 3) = N
Next
End Sub

TOP

¦^´_ 4# ­ã´£³¡ªL
­ã¤j¯uªº¬OLogic Genius...

TOP

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


    ÁÂÁ½׾Â,ÁÂÁ«e½ú«ü¾É
¥H¤U¾Ç²ß¤ß±oµù¸Ñ,½Ð«e½ú¦A«ü¾É

Sub TEST_1()
Dim xR As Range, T$(2), S$(2), N%
'¡ô«Å§iÅܼÆ:xRÅܼƬO Àx¦s®æÅܼÆ,(T,S)ÅܼƬO0~2¯Á¤Þ¸¹ªº¦r¦ê¤@ºû°}¦C,N¬Oµu¾ã¼Æ
For Each xR In Range([a2], [a65536].End(3))
'¡ô³]°j°é!¥OxR¬O [A2]¨ìAÄæ³Ì«á¦³¤º®eÀx¦s®æ½d³ò¤§¤@Àx¦s®æ
    T(1) = xR: T(2) = xR(1, 2)
    '¡ô¥OT°}¦C1¯Á¤Þ¸¹°}¦C­È¬OxR
    '¡ô¥OT°}¦C2¯Á¤Þ¸¹°}¦C­È¬OxR¥k1®æÀx¦s®æ­È

    If T(1) <> S(1) Then S(1) = T(1): S(2) = "\\": N = 0
    '¡ô¦pªGT°}¦C1¯Á¤Þ¸¹°}¦C­È»P S°}¦C1¯Á¤Þ¸¹°}¦C­È¤£¦P?
    '¡ôTrue´N¥OS°}¦C2¯Á¤Þ¸¹°}¦C­È¬O "\\"
    '¡ô¥ONÅܼÆÂk¹s

    N = N - (T(2) <> S(2))
    '¡ô¥ONÅܼƩó((T°}¦C2¯Á¤Þ¸¹°}¦C­È<> T°}¦C2¯Á¤Þ¸¹°}¦C­È)ÅÞ¿è­ÈTrue)®É,
    '²Ö¥[1 µù: -(TRUE) = -(-1) = +1

    S(2) = T(2)
    '¡ô¥OS°}¦C2¯Á¤Þ¸¹°}¦C­È¬O T°}¦C2¯Á¤Þ¸¹°}¦C­È
    xR(1, 3) = N
    '¡ô¥OxR¥k2®æÀx¦s®æ­È¬O NÅܼÆ
Next
End Sub

Sub TEST_2()
Dim xR As Range, T$, TT$, S$, SS$, N%
'¡ô«Å§iÅܼÆ:xRÅܼƬO Àx¦s®æÅܼÆ,(T,TT,S,SS)ÅܼƬO¦r¦êÅܼÆ,N¬Oµu¾ã¼Æ
For Each xR In Range([a2], [a65536].End(3))
'¡ô³]°j°é!¥OxR¬O AÄæÀx¦s®æ¤§¤@
    T = xR: TT = T & "\" & xR(1, 2)
    '¡ô¥OT³o¦r¦êÅܼƬO xRÅܼƭÈ
    '¡ô¥OTT³o¦r¦êÅܼƬO TÅܼƳs±µ"\",¦A³s±µxR¥k1®æÀx¦s®æ­È²Õ¦¨ªº·s¦r¦ê

    N = N * -(T = S) - (TT <> SS)
    '¡ô¥ON³oµu¾ã¼ÆÅܼƬO ¦Û¨­­¼ÅÞ¿è­È«á,¦A§PÂ_ÅÞ¿è­ÈTrue®É,²Ö¥[1
    '1.·í T(¾÷¥x)<>S(«e¾÷¥x) ®É N * -(T = S)·|N*-(0) = N*0 = 0,
    '§_«h N*-(-1) = N*1 = N
    '2.·í ¾÷¥x\§Ç¸¹<>«e¾÷¥x\«e§Ç¸¹ ®É,-(TT <> SS) = -(-1) = 1
    '§_«h -(TT <> SS) = -(0) = 0
    '3.°j°é¤@¶}©lªºSÅܼƻPSSÅܼƳ£¬O"",©Ò¥H(T=S) = FALSE = 0,
    '-(TT <> SS) = -(TRUE) = 1

    S = T: SS = TT
    '¡ô¥OSÅܼƭȬO TÅܼƭÈ(³o¬O­n°O¦í·í¤U¾÷¥xµ¹¤U¤@°j°é¤ñ¸û)
    '¡ô¥OSSÅܼƭȬO TTÅܼƭÈ(³o¬O­n°O¦í²Õ¦X¦r¦êµ¹¤U¤@°j°é¤ñ¸û)

    xR(1, 3) = N
    '¡ô¥OxR¥k2®æÀx¦s®æ­È¬O NÅܼÆ
Next
End Sub
¥Î¦æ°Ê¸Ë¸mÂsÄý½×¾Â¾Ç²ß«Ü¤è«K,ÁÂÁ½׾¸gÀç¹Î¶¤
½Ð¤j®a¤@°_¤W½×¾Â¨Ó¥æ¬y

TOP

¥»©«³Ì«á¥Ñ hcm19522 ©ó 2023-11-9 12:21 ½s¿è

(¿é¤J½s¸¹11979) googleºô§}:https://hcm19522.blogspot.com/
google"EXCEL°g"  blog  ©Îgoogleºô§}:https://hcm19522.blogspot.com/

TOP

        ÀR«ä¦Û¦b : °µ¦n¨Æ¤£¯à¤Ö§Ú¤@¤H¡A°µÃa¨Æ¤£¯à¦h§Ú¤@¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD