☆エコ・RDB 〔11〕一件のデータを検索_SUB

Dim PX As Integer, P1 As Integer, P2 As Integer, CH As Integer, ChX As Integer
Dim ChkDat As Variant, Scp As Variant, Rn As Long, Cn As LongDim Max0 As Long, Max1 As Integer, Max2 As Integer, Max3 As Integer, Max4 As Integer
Dim C_0 As Integer, C_1 As Integer, C_2 As Integer, C_1M As Integer

Dim Sp0 As Integer, Sp1 As Long, Sp2 As Long, Sp3 As Long, Sp4 As Long, SpR As LongDim RCpo1 As Long, RCpo2 As Long, RCpo3 As Long, RCpo4 As Long

Sub Src_Dt_RD2 (MST As Worksheet, IDX As Worksheet, SrcDt As Variant, SrcRn As Variant _
             , ScRn As Long, ScCn As Long, RCpo0 As Integer, BMax As Integer, BCut As Integer, TMP1())
'
' Src_Data Macro
' マクロ記録日 : 2008/10/8  ユーザー名 :寺田屋の龍馬
'
'   一件のマスタデータをRDBシートより検索〔SUB〕

'  Eco_RDB【エコ・RDB】 Ver.2.0

        C_0 = 0: C_1 = 1: C_2 = 2: C_1M = 10000

    'Sub_ID サブIDでの対象のクラスタの検索

        Max1 = IDX.Cells(1, 202)        Max0 = IDX.Cells(2, 202)

        P1 = C_1        P2 = Max1

        PX = Max1 \ C_2 + C_1        CH = C_0: Sp0 = C_1

        If Max1 >= C_2 Then

            While CH <> PX

                Scp = TMP1(PX + (Max1 < PX), 1)
                ChkDat = MST.Cells(Scp Mod C_1M, Scp \ C_1M)
                CH = PX

                If ChkDat > SrcDt Then
                    P2 = PX
                Else
                    If ChkDat = SrcDt Then
                        If Scp > SrcRn Then
                            P2 = PX
                        Else
                            P1 = PX + C_1
                        End If
                    Else
                        P1 = PX + C_1
                    End If
                End If
                PX = (P2 - P1) \ C_2 + P1
            Wend
            Sp0 = PX - (PX < C_1)
            Sp0 = PX + (Max1 < PX)
        End If

        Call Worksheet_SelectionChange(IDX.Range(IDX.Range("A" + CStr(RCpo0 + Sp0)).Formula), Rn, Sp1)

        RCpo1 = Rn - C_1

        If Sp0 >= C_2 Then '検索すべきクラスタを決める

            If MST.Cells(Scp Mod C_1M, Scp \ C_1M) >= InsDt Then

                Call Worksheet_SelectionChange(IDX.Range(IDX.Range("A" + CStr(RCpo0 + Sp0 - C_1)).Formula), Rn, Sp3)
                RCpo3 = Rn - C_1
                Scp = IDX.Cells(RCpo3 + IDX.Cells(RCpo3, Sp3), Sp3)

                If MST.Cells(Scp Mod C_1M, Scp \ C_1M) > InsDt Or (MST.Cells(Scp Mod C_1M, Scp \ C_1M) = InsDt And Scp >= InsRn) Then

                    Sp0 = Sp0 - C_1: Sp1 = Sp3: RCpo1 = RCpo3
                End If            End If
        End If

    'Main_ID クラスタ内でのIDの検索

        Max2 = IDX.Cells(RCpo1, Sp1)

        P1 = C_1        P2 = Max2

        PX = Max2 \ C_2 + C_1        CH = C_0: Sp2 = C_1

        While CH <> PX

            ChX = RCpo1 + PX + (Max2 < PX)
            Scp = IDX.Cells(ChX, Sp1)            ChkDat = MST.Cells(Scp Mod C_1M, Scp \ C_1M)
            CH = PX

            If ChkDat > SrcDt Then
                P2 = PX
            Else
                If ChkDat = SrcDt Then
                    If Scp > SrcRn Then
                        P2 = PX
                    Else
                        P1 = PX + C_1
                    End If
                Else
                    P1 = PX + C_1
                End If
            End If
            PX = (P2 - P1) \ C_2 + P1
        Wend

    Sp2 = PX + (PX > C_1)
    ChX = RCpo1 + Sp2 + (Max2 < Sp2)
    Scp = IDX.Cells(ChX, Sp1)
    ChkDat = MST.Cells(Scp Mod C_1M, Scp \ C_1M)

        '該当するマスタデータのチェック        If Max2 >= Sp2 And (ChkDat = SrcDt) Then

                ScRn = Scp Mod C_1M
                ScCn = Scp \ C_1M        End If
        SrcDt = ChkDat

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range, Rn As Long, Cn As Long)

    Rn = Target.Row

    Cn = Target.Column

End Sub



© Rakuten Group, Inc.
X
Design a Mobile Site
スマートフォン版を閲覧 | PC版を閲覧
Share by: