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

[­ì³Ð] ¨Ì¦Û­q²M³æí©w±Æ§Ç¼Ò²Õ

[­ì³Ð] ¨Ì¦Û­q²M³æí©w±Æ§Ç¼Ò²Õ

¤À¨É­ì³Ð¥N½X¡]¤£³ß¤¤¤å¥N½X¡A½Ð¦Û¦æÂন­^¤å¡^
----------------------------------------------------------
S_¨Ì¦Û­q²M³æí©w±Æ§Ç¼Ò²Õ_01.bas
----------------------------------------------------------
Option Explicit

Public Sub S_¤@ºû°}¦C¨Ì¦Û­q²M³æí©w±Æ§Ç_01(ByRef ­ì©l¤@ºû°}¦C As Variant, ByVal °_­­ As Long, ByVal ¨´­­ As Long, ByVal ¦Û­q²M³æ°}¦C As Variant)

    On Error Resume Next
   
    If °_­­ >= ¨´­­ Then
        Exit Sub
    End If
   
    '------------------------------------------------------
   
    Dim X As Long
   
    Dim ¯Á¤Þ°}¦C() As Long
   
    '------------------------------------------------------
   
    ReDim ¯Á¤Þ°}¦C(°_­­ To ¨´­­) As Long
   
    '------------------------------------------------------
   
    ¤@ºû°}¦C¨Ì¦Û­q²M³æí©w±Æ§Ç ­ì©l¤@ºû°}¦C, ¯Á¤Þ°}¦C, °_­­, ¨´­­, ¦Û­q²M³æ°}¦C
   
    '------------------------------------------------------
   
    Dim ½Æ»s­ì©l¤@ºû°}¦C As Variant
   
    ½Æ»s­ì©l¤@ºû°}¦C = ­ì©l¤@ºû°}¦C
   
    For X = °_­­ To ¨´­­
        ­ì©l¤@ºû°}¦C(X) = ½Æ»s­ì©l¤@ºû°}¦C(¯Á¤Þ°}¦C(X))
    Next X

End Sub

Public Sub S_¤Gºû°}¦C¨Ì¦Û­q²M³æí©w±Æ§Ç_01(ByRef ­ì©l¤Gºû°}¦C As Variant, ByVal ±Æ§Çºû«× As Long, ByVal ±Æ§ÇÁä­È As Long, ByVal °_­­ As Long, ByVal ¨´­­ As Long, ByVal ¦Û­q²M³æ°}¦C As Variant)

    On Error Resume Next
   
    If °_­­ >= ¨´­­ Then
        Exit Sub
    End If
   
    '------------------------------------------------------
   
    Dim X As Long
    Dim Y As Long
   
    Dim Â^¨ú¦¨¤@ºû°}¦C As Variant
    Dim ¯Á¤Þ°}¦C() As Long
   
    '------------------------------------------------------
   
    ReDim Â^¨ú¦¨¤@ºû°}¦C(°_­­ To ¨´­­) As Variant
    ReDim ¯Á¤Þ°}¦C(°_­­ To ¨´­­) As Long
   
    If ±Æ§Çºû«× = 1 Then
        For X = °_­­ To ¨´­­
            Â^¨ú¦¨¤@ºû°}¦C(X) = ­ì©l¤Gºû°}¦C(X, ±Æ§ÇÁä­È)
        Next X
    Else
        For Y = °_­­ To ¨´­­
            Â^¨ú¦¨¤@ºû°}¦C(Y) = ­ì©l¤Gºû°}¦C(±Æ§ÇÁä­È, Y)
        Next Y
    End If
   
    '------------------------------------------------------
   
    ¤@ºû°}¦C¨Ì¦Û­q²M³æí©w±Æ§Ç Â^¨ú¦¨¤@ºû°}¦C, ¯Á¤Þ°}¦C, °_­­, ¨´­­, ¦Û­q²M³æ°}¦C
   
    '------------------------------------------------------
   
    Dim ½Æ»s­ì©l¤Gºû°}¦C As Variant
   
    ½Æ»s­ì©l¤Gºû°}¦C = ­ì©l¤Gºû°}¦C
   
    If ±Æ§Çºû«× = 1 Then
        For X = °_­­ To ¨´­­
            For Y = LBound(­ì©l¤Gºû°}¦C, 2) To UBound(­ì©l¤Gºû°}¦C, 2)
                ­ì©l¤Gºû°}¦C(X, Y) = ½Æ»s­ì©l¤Gºû°}¦C(¯Á¤Þ°}¦C(X), Y)
            Next Y
        Next X
    Else
        For Y = °_­­ To ¨´­­
            For X = LBound(­ì©l¤Gºû°}¦C, 1) To UBound(­ì©l¤Gºû°}¦C, 1)
                ­ì©l¤Gºû°}¦C(X, Y) = ½Æ»s­ì©l¤Gºû°}¦C(X, ¯Á¤Þ°}¦C(Y))
            Next X
        Next Y
    End If

End Sub

Private Sub ¤@ºû°}¦C¨Ì¦Û­q²M³æí©w±Æ§Ç(ByRef ­ì©l¤@ºû°}¦C As Variant, ByRef ¯Á¤Þ°}¦C() As Long, ByVal °_­­ As Long, ByVal ¨´­­ As Long, ByVal ¦Û­q²M³æ°}¦C As Variant)

    On Error Resume Next
   
    Dim X As Long
    Dim N As Long
   
    '------------------------------------------------------
   
    Dim ¦Û­q²M³æ¦r¨å As Object
   
    Set ¦Û­q²M³æ¦r¨å = CreateObject("Scripting.Dictionary")
   
    For X = LBound(¦Û­q²M³æ°}¦C) To UBound(¦Û­q²M³æ°}¦C)
        ¦Û­q²M³æ¦r¨å(¦Û­q²M³æ°}¦C(X)) = 0
    Next X
   
    ¦Û­q²M³æ°}¦C = ¦Û­q²M³æ¦r¨å.Keys
   
    '------------------------------------------------------
   
    For X = °_­­ To ¨´­­
        If ¦Û­q²M³æ¦r¨å.Exists(­ì©l¤@ºû°}¦C(X)) = True Then
            ¦Û­q²M³æ¦r¨å(­ì©l¤@ºû°}¦C(X)) = ¦Û­q²M³æ¦r¨å(­ì©l¤@ºû°}¦C(X)) + 1
            ¯Á¤Þ°}¦C(X) = ¦Û­q²M³æ¦r¨å(­ì©l¤@ºû°}¦C(X))
        Else
            ¦Û­q²M³æ¦r¨å("Key_Not_Exist") = ¦Û­q²M³æ¦r¨å("Key_Not_Exist") + 1
            ¯Á¤Þ°}¦C(X) = ¦Û­q²M³æ¦r¨å("Key_Not_Exist")
        End If
    Next X
   
    '------------------------------------------------------
   
    Dim ¦Û­q²M³æ²Ö¿n¼Æ°}¦C As Variant
    Dim ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å As Object
   
    ¦Û­q²M³æ²Ö¿n¼Æ°}¦C = ¦Û­q²M³æ¦r¨å.Items
   
    Set ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å = CreateObject("Scripting.Dictionary")
   
    ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å(¦Û­q²M³æ°}¦C(0)) = 0
   
    N = 0
    For X = 1 To UBound(¦Û­q²M³æ°}¦C)
        ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å(¦Û­q²M³æ°}¦C(X)) = ¦Û­q²M³æ²Ö¿n¼Æ°}¦C(N)
        N = N + 1
        ¦Û­q²M³æ²Ö¿n¼Æ°}¦C(N) = ¦Û­q²M³æ²Ö¿n¼Æ°}¦C(N - 1) + ¦Û­q²M³æ²Ö¿n¼Æ°}¦C(N)
    Next X
   
    ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å("Key_Not_Exist") = ¦Û­q²M³æ²Ö¿n¼Æ°}¦C(N)
   
    '------------------------------------------------------
   
    For X = °_­­ To ¨´­­
        If ¦Û­q²M³æ¦r¨å.Exists(­ì©l¤@ºû°}¦C(X)) = True Then
            ¯Á¤Þ°}¦C(X) = ¯Á¤Þ°}¦C(X) + ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å(­ì©l¤@ºû°}¦C(X))
        Else
            ¯Á¤Þ°}¦C(X) = ¯Á¤Þ°}¦C(X) + ¦Û­q²M³æ²Ö¿n¼Æ¦r¨å("Key_Not_Exist")
        End If
    Next X
   
    '------------------------------------------------------
   
    Dim ¯Á¤Þ°}¦C°Æ¥» As Variant
   
    ¯Á¤Þ°}¦C°Æ¥» = ¯Á¤Þ°}¦C
   
    For X = °_­­ To ¨´­­
        ¯Á¤Þ°}¦C(°_­­ - 1 + ¯Á¤Þ°}¦C°Æ¥»(X)) = X
    Next X

End Sub
Word§e²{·¥­PªºÀRºA¤§¬ü¡AExcel®i²{·¥­Pªº°ÊºA¤§¬ü¡C

´ú¸ÕÀÉ®×

´ú¸Õ¨Ì¦Û­q²M³æ±Æ§Ç.zip (16.32 KB)

Word§e²{·¥­PªºÀRºA¤§¬ü¡AExcel®i²{·¥­Pªº°ÊºA¤§¬ü¡C

TOP

        ÀR«ä¦Û¦b : ¤p¨Æ¤£°µ¡B¤j¨ÆÃø¦¨¡C
ªð¦^¦Cªí ¤W¤@¥DÃD