Results 1 to 19 of 19

Thread: Adding Two Arrays in VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    May 2015
    Posts
    5
    Location

    Adding Two Arrays in VBA

    Hi
    I am trying to add two arrays with numbers in VBA and finally I will paste/export that summed up array to an excel sheet.

    It is possible, I am not experience in VBA? Basically I want to do the same as taking a range and pastespecial add values onto another range but only keep the range in VBA to save time.

    Here is my code if it helps. Get error Runtime 424 Object required. Any help appreciated.

    Dim i As Integer, j As Integer, vbAntal_kontrakt As Integer, vbTenant_CF As Range, vbPortfolio_CF As Variant, vbTenant_record As Range    Sheets("CASH_FLOW").Range("CFport_clear").ClearContents
        j = 0
        vbAntal_kontrakt = Sheets("Input_tenant_specific").Range("Antal_kontrakt").Value
        For i = 1 To vbAntal_kontrakt
            j = i + 7
            Sheets("Input_tenant_specific").Range(Cells(j, "A").Address, Cells(j, "BV").Address).Copy
            Sheets("Input_tenant_specific").Range("A4:bv4").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False 'Copy each tenant's data to the top row, which then generates monthly cash flows
            Set vbTenant_CF = Sheets("Lease_analysis").Range("Tenant_CF")
            Set vbPortfolio_CF = vbPortfolio_CF.Value + vbTenant_CF.Value 'THIS IS NOT WORKING
        Next i
    vbPortfolio_CF.Copy Destination:=Sheets("CASH_FLOW").Range("Portfolio_CF") = vbPortfolio_CF.Value 'DO NOT KNOW IF THIS IS WORKING
    Last edited by henrik2h; 05-13-2015 at 02:07 PM.

Posting Permissions

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