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

¦p¦ó§ä¥X³sÄòªº¼Æ¦r

¦p¦ó§ä¥X³sÄòªº¼Æ¦r

¤j®a¦n¡A²×©ó¼õ¨ì¤¤¾Ç¥Í¥i¥Hµo°Ý¡A«Ü·PÁ¯঳³o­Ó¾÷·|¯à§ä¨ì·|Excelªº«e½úÀ°¦£

(ªí®æ¸Ô¦pªþ¥ó)
ªí®æ¤ºªºÀH¾÷¼Æ¦r¤w«ö¤j¤p¥Ñ¥ª¦Ü¥k±Æ¦C¡A½Ð°Ý¬O§_¦³¨ç¼Æ©Î¤½¦¡¯à¦C¥X¨C¤@¦C¤¤³sÄòªº¼Æ¦r¡H
(¨Ò¦p¡G1,,3,4,5,9,12,13,...¡A¯àÅã¥Ü¸¹½X³sÄòªÌ¬°3,4,5ÁÙ¦³12,13)
§¹¾ãªº¼Æ¶q¤j·§·|¦³´X¦Ê~2¤d¦C¤£µ¥¡A¤@¦C¦CÀ°¦£ºâ§Ú¥i¯à¨S¿ìªk@@

¦³¥ý·j´M¹L©¹¤å³¹¡A¦ý¦n¹³©M§Úªº°ÝÃD¤£¤Ó¤@¼Ë  (¤p§Ì©Ò¾Ç¬Æ²L¡A¥i¯à¬Ý¹Lµª®×¦Û¤v³£¤£ª¾¹D¡AÁٽЫe½ú­Ì¨£½Ì)

¦A½Ð½×¾Â¤Wªº¤j¯«­ÌÀ°¦£¡C¦A¦¸·PÁ½׾ºûÅ@¹Î¶¤©M¤j®a¯àµ¹§Ú³o­Óµo°Ýªº¾÷·|¡CÁÂÁ¡I

Files.zip (6.89 KB)

½d¨Òªí®æ

²`¤J¬ã¨s¯Ó®É:
³æ´N§PÂ_»P«Ø¥ß¦r¨å®w!´N¯Ó®É0.6¬í
Option Explicit
Sub TEST_4()
Dim Arr, i&, j&, T, V, Y, U1, U2, S, P$
S = Timer
Set Y = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [m65536].End(xlUp))
[O:O].ClearContents
For i = 1 To UBound(Arr)
   V = -9 ^ 9
   For j = 1 To UBound(Arr, 2)
      If j < UBound(Arr, 2) Then
         U1 = Arr(i, j): U2 = Arr(i, j + 1)
         If U1 * U2 >= 0 Then
            Y(U1) = IIf(Y(U1) <> 1, Abs((U2) - (U1)), Y(U1))
            Y(U2) = IIf(Y(U2) <> 1, Abs((U2) - (U1)), Y(U1))
         End If
      End If
   Next
   Y.RemoveAll
Next
MsgBox Timer - S & "’"
End Sub

¥h°£IIF§PÂ_! 0.3¬í!
Option Explicit
Sub TEST_4()
Dim Arr, i&, j&, T, V, Y, U1, U2, S, P$
S = Timer
Set Y = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [m65536].End(xlUp))
[O:O].ClearContents
For i = 1 To UBound(Arr)
   V = -9 ^ 9
   For j = 1 To UBound(Arr, 2)
      If j < UBound(Arr, 2) Then
         U1 = Arr(i, j): U2 = Arr(i, j + 1)
         If U1 * U2 >= 0 Then
            Y(U1) = ""
            Y(U2) = ""
         End If
      End If
   Next
   Y.RemoveAll
Next
MsgBox Timer - S & "’"
End Sub

¥ú¬O¤ÏÂЦr¨å«Ø¥ß/²MªÅ!´N­n 0.25¬í!
Option Explicit
Sub TEST_4()
Dim Arr, i&, j&, T, V, Y, U1, U2, S, P$
S = Timer
Set Y = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [m65536].End(xlUp))
[O:O].ClearContents
For i = 1 To UBound(Arr)
   V = -9 ^ 9
   For j = 1 To UBound(Arr, 2)
      If j < UBound(Arr, 2) Then
         U1 = Arr(i, j)
         Y(U1) = ""
      End If
   Next
   Y.RemoveAll
Next
MsgBox Timer - S & "’"
End Sub

TOP

¦r¨åkeyÂà¸mªº¤è¦¡§ï¦¨°j°éª½±µ¼g¤J°}¦C¤Ö!µy¦n!


Option Explicit
Sub TEST_3()
Dim Arr, i&, j&, T, V, Y, U1, U2, S
S = Timer
Set Y = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [m65536].End(xlUp))
[O:O].ClearContents
For i = 1 To UBound(Arr)
   V = -9 ^ 9
   For j = 1 To UBound(Arr, 2)
      If j < UBound(Arr, 2) Then
         U1 = Arr(i, j): U2 = Arr(i, j + 1)
         If U1 * U2 >= 0 Then
            Y(U1) = IIf(Y(U1) <> 1, Abs((U2) - (U1)), Y(U1))
            Y(U2) = IIf(Y(U2) <> 1, Abs((U2) - (U1)), Y(U1))
         End If
      End If
   Next
   Arr(i, 1) = ""
   For Each T In Y.KEYS
      If Y(T) <> 1 Then
         Y.Remove (T)
         Else
            Arr(i, 1) = Arr(i, 1) & "," & T
      End If
   Next
   Arr(i, 1) = Mid(Arr(i, 1), 2)
   Y.RemoveAll
Next
[O1].Resize(UBound(Arr)) = Arr
MsgBox Timer - S & "’"
End Sub

TOP

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


    ÁÂÁ«e½ú
¦¹©««á¾Ç¥Î°}¦C»P¦r¨å½m²ß¤ß±o¦p¤U
½Ð«e½ú¦A«ü¾É!ÁÂÁÂ
1.¯à¤£¥²¥Î¦r¨å´N¤£­n¨è·N¨Ï¥Î! ¸ê®Æ­Ë¶i­Ë¥X³£»Ý­n®É¶¡
2.¥ÎÅܼƪ½±µ¶Ç»¼°T®§¸û§Ö

«e½úªºµ{¦¡½X°õ¦æ10000¦Cªº®É¶¡:


«á¾Çªºµ{¦¡½X°õ¦æ10000¦Cªº®É¶¡:


Option Explicit
Sub TEST_2()
Dim Arr, i&, j&, T, V, Y, U1, U2, S
S = Timer
Set Y = CreateObject("Scripting.Dictionary")
Arr = Range([A1], [m65536].End(xlUp))
[O:O].ClearContents
For i = 1 To UBound(Arr)
   V = -9 ^ 9
   For j = 1 To UBound(Arr, 2)
      If j < UBound(Arr, 2) Then
         U1 = Arr(i, j): U2 = Arr(i, j + 1)
         If U1 * U2 >= 0 Then
            Y(U1) = IIf(Y(U1) <> 1, Abs((U2) - (U1)), Y(U1))
            Y(U2) = IIf(Y(U2) <> 1, Abs((U2) - (U1)), Y(U1))
         End If
      End If
   Next
   For Each T In Y.KEYS
      If Y(T) <> 1 Then
         Y.Remove (T)
      End If
   Next
   Arr(i, 1) = Join(Application.Transpose(Application.Transpose(Y.KEYS)), ",")
   Y.RemoveAll
Next
[O1].Resize(UBound(Arr)) = Arr
MsgBox Timer - S & "’"
End Sub

TOP

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2022-10-31 10:53 ½s¿è

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


    'ÁÂÁ«e½ú
'³o©«¾Ç¨ì
'1.¸ê®Æ«¬ºA:ªø¾ã¼Æªº³Ì¤p­È ¬O-2147483648
'2.ª¾¹D¤°»ò¬O¼Æ¦r·¸¦ì
'3.¤£¯à¥u¬Ý°ÝÃDªº¥¿­±!­t­±ªº¤]­n¦Ò¼{!²¦³º¥D¨¤¬O¼Æ¦r
'4.¨¾»~§P¬O«Ü­«­nªº¨Æ!
'5.«Ü¦hª¾ÃÑ»P¾Ç°Ý¬O½m²ß¤~¯àÅé·|ªº!
'6.¤Ñ§U¦Û§U¤H§U
½Ð«e½ú¦A«ü¾É!ÁÂÁÂ
Option Explicit
Sub TEST()
Dim Arr, V&, U1&, U2&, i&, j%, T$
'¡ô«Å§iÅܼÆ
Arr = Range([A1], [m65536].End(xlUp))
'¡ô¥OArr¬O°}¦C!­Ë¤J[A1]¨ìMÄæ³Ì«á¤@­Ó¦³¤º®eÀx¦s®æ,ÂX®i¨ì¤è¥¿³Ì¤p°Ï°ìÀx¦s®æ­È
For i = 1 To UBound(Arr)
'¡ô³]¥~¶¶°j°é!±q1¨ìArr°}¦CÁa¦V³Ì«á¤@¦C¼Æ
    V = -9 ^ 9
    '¡ô¥OV¼Æ¦r¬O9ªº9¦¸¤è­t­È=(9 ^ 9)*(-1)= -387420489
    '¬d¸ß¤FVBA ªº¸ê®Æ«¬ºA: V& ªø¾ã¼Æªº³Ì¤p­È ¬O-2147483648 !
    '¬°¤°»ò¤£¥Î¥¦·íV­È??  ¦]¬°«á¤èµ{§Ç·|ÅýÅܼƷ¸¦ì(¤ñ -2147483648 §ó¤p)
    '¦]¬°Vªºªì©l­È¬O0 ¦pªG¤@¶}©l¨S¦³µ¹V¤@­Ó²Ä¤@¨Ï¥Î­È
    '«á¤èªºµ{§Ç·|»~§P[A1]=1 ®É³sÄò

    For j = 1 To UBound(Arr, 2)
    '¡ô³]¤º¶¶°j°é!±q1¨ìArr°}¦C¾î¦V³Ì«á¤@Äæ¼Æ
        U1 = Arr(i, j)
        '¡ô¥OU1¬OArr°}¦C¤º¥~°j°éªº¥D¨¤(¼Æ¦r)
        U2 = U1
        '¡ôU2 = U1¬O¬°¤F ®ø°£U2¦b«e¦¸°j°é¤¤´Ý¾l¼Æ¦r(U2ªì©l­È¬O0)
        If j < UBound(Arr, 2) Then
        '¡ô¦pªGj³o¤º°j°é¼Æ¤p©ó Arr°}¦C¾î¦V³Ì«á¤@Äæ¼Æ
           U2 = Arr(i, j + 1)
           'U2´NÅܤߦ¨¬° U1¥D¨¤¥kÃä®æªº¨º­Ó­È(¼Æ¦r)
        End If
        If U1 - V = 1 Or U2 - U1 = 1 Then
        '¡ô¦pªG¥D¨¤U1 - V =1,¬O­n§PÂ_­t¼Æ­Èªº³sÄò
        '©Î ÅܤßU2ªº-¥D¨¤U1=1

           T = T & "," & U1
           '¡ô¥OT =T¦r¦ê³s±µ "," ²Å¸¹ ,¦A³s±µ¥D¨¤U1
           V = U1
           '¡ô¥OV¼Æ¦r¬O¥D¨¤U1­È
        End If
    Next j
    Arr(i, 1) = Mid(T, 2)
    '¡ô¥O¥~°j°éArr°}¦Cªº²Ä¤@Äæ¨ú¤º°j°é T¦r¦ê¸Ìªº²Ä2­Ó¦r¶}©l(§t¦Û¤v)ªº¥þ³¡¦r¦ê
    '¡ôMid(T, 2)«á¾Ç¤µ¤Ñ¤~ª¾¹D¥i¥H³o¼Ë³¯­z!¥H«e³£¥ÎMid(T, 2,99)
    '¦]¬°²Ä¤@­Ó¦r¬O "," ²Å¸¹

    T = ""
    '¡ô¥O²MªÅ T¦r¦ê
Next i
[O1].Resize(UBound(Arr)) = Arr
'¡ôArr°}¦C ±q[O1]¶}©l¶K¤J Arr°}¦CÁa¦V³Ì«á¤@¦C¼Æ,¥u¶K¤J1Äæ¦ì¸ê®Æ
'¦P[O1].Resize(UBound(Arr), 1) = Arr,1¥i¥H¬Ù²¤
End Sub

°õ¦æ«e:


°õ¦æµ²ªG:

TOP

ÁÂÁ¤j®a¡A§Ú¦A§ä®É¶¡¦n¦n¤F¸Ñ¨C­Ó¸Ñ¤è¡C

¦A¦¸·PÁ¡I¡I

TOP

·PÁ­ã¤j²Ó¤ß¡A¤S¾Ç¨ì¤p§Þ¥©¡A§ó·s¦p¤U¡AÁÂÁÂ

Sub tt3()
Dim Arr, TT, T%, T1%, L&, i&, j&
[o1].CurrentRegion = ""
Arr = [a1].CurrentRegion
For i = 1 To UBound(Arr)
    L = 9 ^ 9
    For j = 1 To UBound(Arr, 2)
        If j < UBound(Arr, 2) Then T1 = Arr(i, j + 1)
        T = Arr(i, j)
        If T1 - T = 1 Or T - L = 1 Then
            TT = TT & "," & T: L = T
        End If
    Next
    Arr(i, 1) = Mid(TT, 2): TT = ""
Next
Range("o1").Resize(UBound(Arr)) = Arr
End Sub

TOP

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


·PÁ­ã¤j«ü¾É¡A¯uªº¦³°ÝÃD¡A¦³ªÅ®É¦A¨Ó·Q¬Ý¬Ý¦p¦ó¸Ñ¡A·PÁ¡C

TOP

¦^´_ 13# samwang


A1 §ï¦¨ 1 ¸Õ¸Õ~~

TOP

¦^´_ 1# f00l01

¥þ³¡³sÄò­ÈÅã¥Ü¦b¦P¤@®æÀx¦s®æ¦p·Ó¤ù¡A½Ð´ú¸Õ¬Ý¬Ý¡AÁÂÁ¡C
Sub tt2()
Dim Arr, TT, T%, T1%, L%, i&, j&
[o1].CurrentRegion = ""
Arr = [a1].CurrentRegion
For i = 1 To UBound(Arr)
    L = 0
    For j = 1 To UBound(Arr, 2)
        If j < UBound(Arr, 2) Then T1 = Arr(i, j + 1)
        T = Arr(i, j)
        If T1 - T = 1 Or T - L = 1 Then
            TT = TT & "," & Arr(i, j): L = T
        End If
    Next
    Arr(i, 1) = Mid(TT, 2): TT = ""
Next
Range("o1").Resize(UBound(Arr)) = Arr
End Sub

Â^¨ú.PNG (14.73 KB)

Â^¨ú.PNG

TOP

        ÀR«ä¦Û¦b : ¹ï¤÷¥À­nª¾®¦¡A·P®¦¡B³ø®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD