title: VBA Array is being transposed into the second column of a range, not sure why?
body: <p>I have the below VBA code which calculates a number of output values and stores them in as an array (beginning_gross_facility_balance being one of the examples).</p>
  <p>when I try to print the resulting array values into excel (to output2 range, which is  C16:J515 in an excel tab, the array is exported/printed into column D and from row 17.</p>
  <p>currently, i = 1 and j = 25</p>
  <p>grateful if someone could shine some light on why this is happening/how can I ensure that the output is copied into the first column and first row of the range</p>
  <p>Sub AssetProjection2()</p>
  <p>Application.ScreenUpdating = False</p>
  <pre><code>'pluming variables
  Dim i As Integer
  Dim j As Integer
  
  Dim Period As Integer
  Dim numberOfLoans As Integer
  numberOfLoans = WorksheetFunction.CountA(Range(&quot;LoanCount&quot;)) - 1
  ReDim tape(numberOfLoans)
  Dim pool_lag As Double
  Dim total_gross_facility_limit As Double
  Dim beginning_gross_facility_balance(500, 500) As Double
  Dim interest_rate As Double
  Dim arrangement_fee As Double
  Dim admin_fee As Double
  Dim Audit_fee As Double
  Dim insurance_fee As Double
  Dim exit_fee As Double
  Dim loan_term As Double
  Dim loan_remaining_term As Double
  Dim default_flag As String
  Dim GDV As Double
  'only relevant for loans with no seasoning
  Dim first_tranche_percentage As Double
  Dim seasoning As Double
  Dim adjustment_factor As Double
  Dim development_fees As Double
  Dim lag As Double
  Dim sev As Double
  
  
  'temps/ output variables on a loan by loan basis (so i can call info from any period and any loan)
  
  Dim pmt As Double
  Dim Recovery As Double
  Dim TempDefault(500, 500) As Double
  'end of period balance is the cumulative gross facility at any given point, at maturity, this should match total gross loan limit
  Dim end_of_period_gross_balance(500, 500) As Double
  Dim periodic_interest(500, 500) As Double
  Dim cumulative_retained_interest(500, 500) As Double
  Dim periodic_gross_drawdown(500, 500) As Double
  Dim periodic_net_advance(500, 500) As Double
  Dim cumulative_net_advance(500, 500) As Double
  'the loan redeems in one go, then principal and interest redemptions are split for transparency
  Dim total_facility_repayment(500, 500) As Double
  Dim principal_redemption(500, 500) As Double
  Dim interest_redemption(500, 500) As Double
  
  
  'pristine/stressed variables
  Dim prin As Double
  Dim prepay As Double
             
  'scenarios
  Dim DefScen As Integer
  Dim PrepScen As Integer
  Dim SevScen As Integer
  Dim LagScen As Integer
  Dim IRScen As Integer
  
  'ouput variables
  
  
  
  'the below is currently not being used
  Dim oBegBalance(500) As Double
  Dim oEndBalance(500) As Double
  Dim oDefault(500) As Double
  Dim oInterest(500) As Double
  Dim oPrincipal(500) As Double
  Dim oPrepayment(500) As Double
  Dim oRecovery(500) As Double
  Dim oAccrued(500) As Double
  Dim oCumTheoreticalDef(500) As Double
  
  'initialise CF time
  Period = 1
  pool_lag = Range(&quot;total_lag&quot;).Value
  
    
  'this loop will project asset cashflows assuming non-seasonality, then the next loop will look-up the figures for each loan based on the loan's seasonality
  
  For i = 1 To numberOfLoans
  SevScen = Range(&quot;severity_scen&quot;).Cells(i + 1)
  LagScen = Range(&quot;lag_scen&quot;).Cells(i + 1)
  'IR scenario currently not in use, when floating interest is modelled, this will be already plugged in
  IRScen = Range(&quot;IR_scen&quot;).Cells(i + 1)
  interest_rate = Range(&quot;interest_rate&quot;).Cells(i + 1)
  loan_remaining_term = Range(&quot;loan_remaining_term&quot;).Cells(i + 1)
  loan_term = Range(&quot;loan_term&quot;).Cells(i + 1)
  seasoning = loan_term - loan_remaining_term
  first_tranche_percentage = Range(&quot;first_tranche_percentage&quot;).Cells(i + 1)
  total_gross_facility_limit = Range(&quot;total_gross_limit&quot;).Cells(i + 1)
  adjustment_factor = 1.1
  admin_fee = Range(&quot;admin_fee&quot;).Cells(i + 1)
  default_flag = Range(&quot;default_flag&quot;).Cells(i + 1)
      For j = 1 To loan_term + pool_lag
      lag = Range(&quot;LagScenarios&quot;).Cells(loan_term + j + 4, LagScen)
      sev = Range(&quot;severityScenarios&quot;).Cells(loan_term + j + 4, SevScen)
          If j = 1 Then
          arrangement_fee = Range(&quot;arrangement_fee&quot;).Cells(i + 1)
          Audit_fee = Range(&quot;Audit_fee&quot;).Cells(i + 1)
          insurance_fee = Range(&quot;insurance_fee&quot;).Cells(i + 1)
          Else
          arrangement_fee = 0
          Audit_fee = 0
          insurance_fee = 0
          End If
          If j = loan_term Then
              exit_fee = Range(&quot;exit_fee&quot;).Cells(i + 1)
          Else
              exit_fee = 0
          End If
          development_fees = arrangement_fee + Audit_fee + insurance_fee + admin_fee
          Recovery = 0
          'term is original term, not really used anywhere at the moment, only as a static figure to work out seasonality for input curves
          loan_term = Range(&quot;loan_term&quot;).Cells(i + 1)
          'remaining term doesnt need to be dynamic as the PMT formula takes the current J into account to work out the dynamic remaining term
          loan_remaining_term = Range(&quot;loan_remaining_term&quot;).Cells(i + 1)
          interest_rate = Range(&quot;interest_rate&quot;).Cells(i + 1)
          
          If j = 1 Then
              beginning_gross_facility_balance(i, j) = total_gross_facility_limit * first_tranche_percentage
              Else
              beginning_gross_facility_balance(i, j) = end_of_period_gross_balance(i, j - 1)
          End If
          
          'gross drawdown. if first disbursment, it's first_tranche_percentage, else, it's a fixed figure such that from month 2 to maturity, the total gross facility equals the gross loan limit. for the model, I will start with a basic number and learn how to apploy a goal  seek/solver figure
          'draws happen at the beginning of the period and so every period's accrued interest is on the end of period balance J - 1 + period J further draw (J=1 has end of previous period as 0 bcs the loan is new
          
          If j = 1 Then
              periodic_gross_drawdown(i, j) = 0
              
              Else
                  If j &lt; loan_term Then
                  
                  periodic_gross_drawdown(i, j) = (total_gross_facility_limit - periodic_gross_drawdown(i, 1)) / (loan_term - 2) / adjustment_factor
                  
                  Else
                  
                  periodic_gross_drawdown(i, j) = 0
                  
                  End If
          End If
              
          If j = 1 Then
          periodic_net_advance(i, j) = beginning_gross_facility_balance(i, j) - development_fees
          Else
          periodic_net_advance(i, j) = periodic_gross_drawdown(i, j) - development_fees
          End If
          
          If j = 1 Then
              cumulative_net_advance(i, j) = periodic_net_advance(i, j)
              Else
              cumulative_net_advance(i, j) = cumulative_net_advance(i, j - 1) + periodic_net_advance(i, j)
          End If
          
          
          periodic_interest(i, j) = (beginning_gross_facility_balance(i, j) + periodic_gross_drawdown(i, j)) * interest_rate
          
          
          end_of_period_gross_balance(i, j) = beginning_gross_facility_balance(i, j) + periodic_interest(i, j)
          
          If j = loan_term And default_flag = &quot;N&quot; Then
              
              total_facility_repayment(i, j) = end_of_period_gross_balance(i, j)
              principal_redemption(i, j) = cumulative_net_advance(i, j)
              interest_redemption(i, j) = total_facility_repayment(i, j) - principal_redemption(i, j)
              
          Else
              total_facility_repayment(i, j) = 0
              principal_redemption(i, j) = 0
              interest_redemption(i, j) = 0
          End If
              
          
          If j = loan_term + lag And default_flag = &quot;Y&quot; Then
                  Recovery = total_facility_repayment(i, j - lag) * (1 - sev) 'accrue some defaulted int rate or keep it simple?
              Else
                  Recovery = 0
              End If
          Next j
          
      Next i
      
              
  
  'write it out
  'Range(&quot;beginning_balance_output&quot;) = WorksheetFunction.Transpose(beginning_gross_facility_balance)
  Range(&quot;output2&quot;) = WorksheetFunction.Transpose(beginning_gross_facility_balance)
  ' Range(&quot;output2&quot;).Columns(3) = WorksheetFunction.Transpose(periodic_net_advance)
  'Range(&quot;output2&quot;).Columns(4) = WorksheetFunction.Transpose(cumulative_net_advance)
  ' Range(&quot;output2&quot;).Columns(5) = WorksheetFunction.Transpose(total_facility_repayment)(end_of_period_gross_balance)
  
  End Sub
  </code></pre>