Reputation: 47
My code below, to add in a series of column headers, does not add the first header "Account ID" to the first column. Instead, cell A1 is populated with "# Pmts." I cannot find why this would happen. My workaround at the moment is to add in a second "Account ID".
Sub Create_Transaction_Notes()
Dim DSA As Worksheet
Set DSA = Worksheets("DEBT_SALE_ACTIVITY")
Dim LF As Worksheet
Set LF = Worksheets("LOAD_FILE")
Dim myArray As Variant
Dim myCount As Integer
'Add in the column titles
DSA.Activate
myArray = Array("Account ID", "# Pmts.", "Total value Pmts.", _
"Avg. Pmt. value", "# Purchases", "Total purch. value", _
"Avg. purch. value", "# Cash adv.", "Total cash adv. value")
With DSA
For myCount = 1 To UBound(myArray)
.Cells(1, myCount).Value = myArray(myCount)
Next myCount
End With
Upvotes: 0
Views: 42
Reputation: 22876
No need for loop:
[DEBT_SALE_ACTIVITY!A1:I1] = Array("Account ID", "# Pmts.", "Total value Pmts.", _
"Avg. Pmt. value", "# Purchases", "Total purch. value", _
"Avg. purch. value", "# Cash adv.", "Total cash adv. value")
Upvotes: 2
Reputation: 371
Arrays in VBA start with 0 by default. Change your for statement to
For myCount = 0 To UBound(myArray)
Upvotes: 1