+ Reply to Thread
Results 1 to 5 of 5

Calculation using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    06-15-2022
    Location
    bengladesh
    MS-Off Ver
    2016
    Posts
    26

    Calculation using VBA

    Hi Freinds,

    i would like to get any help in solving this issue, I got two set of data 1. transactions 2. interest %, are you able to get an interest statement out of this using a VBA, as we need to copy data each time into this sheet

    please see attached, thanks
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Calculation using VBA

    Try this code:
    Sub ArrangeTables()
    Dim Lr1&, Lr2, Ta&, Tb&, X&
    Dim A, B
    
    With Sheets("Sheet1")
    Lr1 = .Range("A2").End(xlDown).Row: Lr2 = .Range("A14").End(xlDown).Row
    A = .Range("A2:D" & Lr1): B = .Range("A15:C" & Lr2).Resize(, 7)
    
    For Ta = 1 To UBound(B, 1)
    B(Ta, 6) = B(Ta, 3): B(Ta, 3) = ""
    Next Ta
    End With
    
    With Sheets("Sheet2")
    .Activate
        With .Range("A4")
        .CurrentRegion.Resize(, 7).Clear
        .Resize(UBound(A, 1), 4) = A
        .End(xlDown).Offset(1, 0).Resize(UBound(B, 1), 7) = B
            With .CurrentRegion.Resize(, 7)
            .Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlNo
            .Columns(5).Formula = "=A5-A4"
            End With
        .End(xlDown).Offset(0, 4) = ""
        End With
    For Tb = 5 To .Range("A4").End(xlDown).Row
    If .Range("F" & Tb) = "" Then .Range("F" & Tb) = .Range("F" & Tb - 1)
    Next Tb
    End With
    
    End Sub
    Dates in Sheet1 and 'interest journal' were not matching. I have corrected the mistakes.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 03-19-2023 at 06:26 AM.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  3. #3
    Registered User
    Join Date
    06-15-2022
    Location
    bengladesh
    MS-Off Ver
    2016
    Posts
    26

    Re: Calculation using VBA

    Thank you very much, appreciated your generous mind. It will help us. but I would like to add, [/U]the balance amount [U] and interest amount is not calculated, if it be possible , it will help us better, thank you very much sir

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Calculation using VBA

    Code modified.
    Sub ArrangeTables()
    Dim Lr1&, Lr2, Ta&, Tb&, X&
    Dim A, B
    
    With Sheets("Sheet1")
    Lr1 = .Range("A2").End(xlDown).Row: Lr2 = .Range("A14").End(xlDown).Row
    A = .Range("A2:D" & Lr1): B = .Range("A15:C" & Lr2).Resize(, 7)
    
    For Ta = 1 To UBound(B, 1)
    B(Ta, 6) = B(Ta, 3): B(Ta, 3) = ""
    Next Ta
    End With
    
    With Sheets("Sheet2")
    .Activate
        With .Range("A4")
        .CurrentRegion.Resize(, 7).Clear
        .Resize(UBound(A, 1), 4) = A
        .End(xlDown).Offset(1, 0).Resize(UBound(B, 1), 7) = B
            With .CurrentRegion.Resize(, 7)
            .Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlNo
            .Columns(5).Formula = "=A5-A4"
            .Columns(7).Formula = "=D4*(E4/365)*F4/100"
            .Columns(7).NumberFormat = "0.00"
            End With
        .End(xlDown).Offset(0, 4) = ""
        End With
    For Tb = 5 To .Range("A4").End(xlDown).Row
    If .Range("F" & Tb) = "" Then .Range("F" & Tb) = .Range("F" & Tb - 1)
    Next Tb
    End With
    
    End Sub

  5. #5
    Registered User
    Join Date
    06-15-2022
    Location
    bengladesh
    MS-Off Ver
    2016
    Posts
    26

    Re: Calculation using VBA

    Thank you very much, it helps me a lot

+ 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. CUMIPMT calculation doesn't seem to match interest calculation from amortization table
    By cdub39 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 11-28-2021, 08:11 PM
  2. Replies: 10
    Last Post: 07-22-2019, 06:27 AM
  3. [SOLVED] VBA to open a workbook with manual calculation and close with automatic calculation
    By thedunna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2019, 12:28 PM
  4. [SOLVED] Calculation of dates and leaving blank cell when calculation sees non-date values
    By Hedy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2018, 07:52 AM
  5. Replies: 0
    Last Post: 05-17-2014, 10:18 PM
  6. Replies: 1
    Last Post: 01-15-2013, 08:51 AM
  7. [SOLVED] Conditional statement calculation based on result of previous calculation.(Need some help)
    By takeprofit in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-01-2012, 01:45 AM

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