+ Reply to Thread
Results 1 to 2 of 2

Populate data in a different sheet using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    12-04-2014
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    2

    Post Populate data in a different sheet using VBA

    Hello,

    I am trying to develop a simple tracker for my parents to manage their retirement expenses based on the fixed income cash-flows.

    BACKGROUND
    I am using MS Office 2013.

    The sample tracker (attached) has four sheets. The first sheet gives an overview of expected credit(s) into their bank account that are not yet (manually) verified.
    The second sheet allows them to easily record new bank deposits.

    PROBLEM_STATEMENT
    My problem is with the third and fourth sheets. I need to populate these sheets with the additional data needed for the tracker to work efficiently. I am looking for help to copy the data from the "Input" worksheet into the next empty row of the "FD_Master" sheet. Also need to auto-increment the FD_ID field.

    I am confident that I can extend this logic to populate the "Payment_Master" worksheet, if I get any helpful pointers. I have pre-populated these sheets with some sample data for a better understanding of my problem/challenge.

    Finally, I am trying to parse the records in the "Payment_Master" every time the workbook is opened to display the expected payouts from the fixed deposits that can then be verified against the various bank statements.

    Appreciate any assistance with the VBA code to populate the "FD_Master" and/or the "Payment_Master"

    Thanks in advance,
    Ravi
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-04-2014
    Location
    Dubai
    MS-Off Ver
    2013
    Posts
    2

    Re: Populate data in a different sheet using VBA

    UPDATE: After mucking around these forum posts, I managed to populate the desired records using the following macro code. I would love to receive feedback on making this code more efficient/elegant or maintenance friendly. I have attached the working Excel spreadsheet for ease of following my logic.

    Sub recordFD()
        Dim fdRef As String
        Dim fdBank As String
        Dim fdDate As Date
        Dim fdPayout As Long
        Dim fdPeriod As Long
        Dim fdAmount As Long
        Dim fdRate As Double
        Dim fdID As Long
      
        'Move the range values to local variables
       With Worksheets("Input")
            fdRef = Range("FD_REF").Value
            fdBank = Range("FD_BANK").Value
            fdDate = Range("FD_START").Value
            fdPayout = Range("FD_FREQ").Value
            fdPeriod = Range("FD_PERIOD").Value
            fdAmount = Range("FD_AMOUNT").Value
            fdRate = Range("FD_RATE").Value
        End With
      
        'Clear the input range as a feedback to the user.
       Range("C3:C9").ClearContents
      
        Dim lastRow As Long
        Dim eRow As Long
        'Select the FD_Master worksheet and find the last populated row number
       Worksheets("FD_Master").Select
        With Worksheets("FD_Master")
            lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
            'Calculate the row number for the entry of records
           eRow = lastRow + 1
            fdID = lastRow
            Range("A" & eRow).Value = lastRow
            Range("B" & eRow).Value = fdBank
            Range("C" & eRow).Value = fdDate
            Range("D" & eRow).Value = fdPeriod
            Range("E" & eRow).Value = fdPayout
            Range("F" & eRow).Value = fdAmount
            Range("G" & eRow).Value = fdRate
            Range("H" & eRow).Value = fdRef
        End With
      
        Dim i As Long
        Dim nextPaymentOn As Date
        Dim lastPayDate As Date
        Dim tPayouts As Long
        lastRow = 0
        eRow = 0
        'Select the Payment_Master worksheet and find the last populated row number
       Worksheets("Payment_Master").Select
        With Worksheets("Payment_Master")
            lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
            tPayouts = fdPeriod / fdPayout
            lastPayDate = fdDate
            For i = 1 To tPayouts
                'Calculate the row number for the entry of records
               eRow = lastRow + 1
              
                Range("A" & eRow).Value = lastRow
                Range("B" & eRow).Value = fdID
                nextPaymentOn = nextPayDate(lastPayDate, fdPayout)
                Range("C" & eRow).Value = nextPaymentOn
                lastPayDate = nextPaymentOn
                Range("D" & eRow).Value = fdAmount * fdRate / tPayouts
                Range("E" & eRow).Value = "No"
              
                'Increment the lastRow counter
               lastRow = lastRow + 1
            Next i
          
       End With
      
    End Sub
    
    Public Function nextPayDate(fdLastPayout As Date, fdPeriod As Long) As Date
        nextPayDate = DateAdd("m", fdPeriod, fdLastPayout)
    End Function
    Attached Files Attached Files

+ 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. [SOLVED] VBA to Auto Populate the “AutoPopulate” sheet as data is being entered in EnterData sheet
    By bjnockle in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-13-2014, 09:10 AM
  2. Replies: 2
    Last Post: 10-22-2013, 08:04 AM
  3. [SOLVED] Populate summary sheet with values within specific month column on data sheet...
    By blue91 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-12-2013, 12:11 PM
  4. Replies: 0
    Last Post: 04-16-2013, 07:29 AM
  5. [SOLVED] Excel VBA: Dropdown box selection in first sheet to populate 2nd sheet from 3rd sheet data
    By EMLalan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-07-2012, 09:46 AM

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