+ Reply to Thread
Results 1 to 4 of 4

Create vba macro to extract balances from statement

  1. #1
    Registered User
    Join Date
    09-17-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    3

    Create vba macro to extract balances from statement

    Hi All,

    I am new to VBA and need your help to create a macro that will help to extract deposit amount from different months for each account from a statement. There could be up to 12 months statement for each account and statement can have 1, 2 or up to 5 accounts. Please refer to the attachment for example statement.

    Hope this will not be as big as it sounds to me.

    Thank you in advance.

    vkyjoshi
    Attached Files Attached Files

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello vkyjoshi,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166
    Hello vkyjoshi,

    Welcome to Excelforum. Be a part of large Excel community. Enjoy Learning.

  4. #4
    Registered User
    Join Date
    09-17-2016
    Location
    India
    MS-Off Ver
    2013
    Posts
    3

    Re: Create vba macro to extract balances from statement

    This has been solved by Excel Forum experts. here is the code, if someone runs in the similar problem:

    Sub test()
    Dim coll As New Collection, arr, i As Long, j As Long, strKey As String, v1, v2, total
    With Sheets("Sheet1")
    arr = .Range("B6:B" & Application.Max(.Cells(.Rows.Count, "B").End(xlUp).Row, 6))
    For i = 1 To UBound(arr, 1)
    If InStrB(1, arr(i, 1), "IMAGE:") Then
    strKey = ""
    For j = 1 To Len(arr(i + 2, 1))
    If IsNumeric(Mid$(arr(i + 2, 1), j, 1)) Then strKey = Mid$(arr(i + 2, 1), j): Exit For
    Next j
    If Len(strKey) Then
    On Error Resume Next
    coll.Add Key:=strKey, Item:=New Collection
    If Err.Number = 0 Then coll(strKey).Add "Account number " & strKey
    On Error GoTo 0
    End If
    i = i + 2
    End If
    If InStrB(1, arr(i, 1), "Account summary") Then coll(strKey).Add Val(Replace$(arr(i + 2, 1), "All deposits in account $", ""))
    Next i
    ReDim arr(1 To 14, 1 To coll.Count)
    j = 0
    For Each v1 In coll
    j = j + 1
    i = 0
    total = 0
    For Each v2 In v1
    i = i + 1
    arr(i, j) = v2
    total = total + Val(v2)
    Next v2
    arr(14, j) = total
    Next v1
    With .Range("D21").Resize(UBound(arr, 1), UBound(arr, 2))
    .Value = arr
    .NumberFormat = "$#,##0.00"
    .Borders.Weight = xlThin
    End With
    End With
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Want Split Alpha Numerials and then compare the balances from 2 sheets using macro
    By aravindkm in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 04-06-2015, 11:51 PM
  2. [SOLVED] Macro to check balances are zero
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-31-2013, 10:51 AM
  3. Replies: 13
    Last Post: 04-18-2013, 12:32 PM
  4. Can I create an excel macro to search & extract certain information from a pdf file?
    By razabear in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2011, 02:37 AM
  5. Replies: 13
    Last Post: 03-09-2009, 08:11 AM
  6. Replies: 2
    Last Post: 01-28-2009, 06:34 AM
  7. Replies: 0
    Last Post: 10-14-2005, 11:05 PM

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