Results 1 to 16 of 16

statement reconciliation

Threaded View

  1. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: statement reconciliation

    When you give us sample data and the results, NEED TO BE ACCURATE.
    No idea why result in unreconciled sheet contains so many data that are not in statement sheet.

    This is still my guess.
    Sub test()
        Dim a, i As Long, t As Long, dic As Object
        Const keyCol As Long = 9, sumCol As Long = 5
        Set dic = CreateObject("Scripting.Dictionary")
        a = Sheets("statement").[a4].CurrentRegion.Value
        For i = 2 To UBound(a, 1)
            If Not dic.exists(a(i, keyCol)) Then
                dic(a(i, keyCol)) = Array(CreateObject("Scripting.Dictionary"), _
                                    CreateObject("Scripting.Dictionary"))
            End If
            t = IIf(a(i, sumCol) >= 0, 0, 1)
            dic(a(i, keyCol))(t)(a(i, sumCol)) = Trim$(dic(a(i, keyCol))(t)(a(i, sumCol)) & " " & i)
        Next
        Reconciled a, dic
        Unreconciled a, dic
    End Sub
    
    Sub Reconciled(a, dic As Object)
        Dim e, s, w, x, y, temp
        Dim i As Long, ii As Long, n As Long
        ReDim b(1 To 1)
        For Each e In dic
            For Each s In dic(e)(0)
                If dic(e)(1).exists(s * -1) Then
                    x = Split(dic(e)(0)(s))
                    y = Split(dic(e)(1)(s * -1))
                    For i = 0 To Application.Min(UBound(x), UBound(y))
                        ReDim temp(1 To UBound(a, 2) * 2 + 1)
                        For ii = 1 To UBound(a, 2)
                            temp(ii) = a(y(i), ii)
                            temp(ii + UBound(a, 2) + 1) = a(x(i), ii)
                        Next
                        b(UBound(b)) = temp
                        ReDim Preserve b(1 To UBound(b) + 1)
                        x(i) = "": y(i) = ""
                    Next
                    x = Trim$(Join(x))
                    If x = "" Then
                        dic(e)(0).Remove s
                    Else
                        dic(e)(0)(s) = x
                    End If
                    y = Trim$(Join(y))
                    If y = "" Then
                        dic(e)(1).Remove s * -1
                    Else
                        dic(e)(1)(s * -1) = y
                    End If
                End If
            Next
        Next
        ReDim Preserve b(1 To UBound(b) - 1)
        With Sheets("reconciled")
            .Rows("5:" & Application.Max(5, .Cells.SpecialCells(11).Row)).ClearContents
            If b(1)(1) <> "" Then
                ReDim Preserve b(1 To UBound(b) - 1)
                .[a5].Resize(UBound(b), UBound(a, 2) * 2 + 1) = Application.Index(b, 0, 0)
            End If
        End With
    End Sub
    
    
    Sub Unreconciled(a, dic)
        Dim e, s, v, x, n As Long, i As Long, ii As Long, temp
        ReDim b(1 To 1), c(1 To 1), temp(1 To UBound(a, 2))
        For Each e In dic
            n = 0
            For i = 0 To 1
                For Each s In dic(e)(i)
                    For Each v In Split(dic(e)(i)(s))
                        For ii = 1 To UBound(a, 2)
                            temp(ii) = a(v, ii)
                        Next
                    Next
                    If i = 0 Then
                        b(UBound(b)) = temp
                        ReDim Preserve b(1 To UBound(b) + 1)
                    Else
                        c(UBound(c)) = temp
                        ReDim Preserve c(1 To UBound(c) + 1)
                    End If
                Next
            Next
        Next
        With Sheets("unreconciled")
            .Rows("5:" & Application.Max(5, .Cells.SpecialCells(11).Row)).ClearContents
            If b(1)(1) <> "" Then
                ReDim Preserve b(1 To UBound(b) - 1)
                .[a5].Resize(UBound(b), UBound(a, 2)) = Application.Index(b, 0, 0)
            End If
            If c(1)(1) <> "" Then
                ReDim Preserve c(1 To UBound(c) - 1)
                .[n5].Resize(UBound(c), UBound(a, 2)) = Application.Index(c, 0, 0)
            End If
        End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How does match personal expenses with the bank statement (reconciliation) ?
    By Jeferson11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2019, 09:00 PM
  2. Automatic Bank Reconciliation Statement with Macros
    By krishco in forum Excel General
    Replies: 1
    Last Post: 04-06-2018, 02:17 AM
  3. Reconciliation Help
    By giryan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-19-2017, 03:34 PM
  4. Bank statement and cashbook reconciliation
    By acube4gh in forum Excel General
    Replies: 2
    Last Post: 06-20-2016, 02:33 PM
  5. [SOLVED] IF statement with 3 conditions for Reconciliation
    By rz6657 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-26-2016, 09:34 AM
  6. A Bank Statement Reconciliation template
    By slidergirl1 in forum Excel General
    Replies: 1
    Last Post: 07-22-2006, 03:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1