I am getting the following error in my code (Item cannot be found in the collection corresponding to the requested name or ordinal), but havent been able to find a solution. It seems to bomb out on "AccountNumber".
Code:
If ThisWorkbook.Sheets("Account Level").Cells(6, 40).Value = "Y" Then
SQL = "SELECT ExceptionYield_Accts.AccountNumber,ExceptionYield_Accts.[Key Account Int], ExceptionYield_Accts.Name, " & _
"ExceptionYield_Accts.Current_Balance, ExceptionYield_Accts.Average_Balance, " & _
"ExceptionYield_Accts.Base_Rate, ExceptionYield_Accts.Rate_w_Bomus " & _
"FROM ExceptionYield_Accts " & _
"WHERE [Key Account Int]=" & CustVal & ""
'loop through data population
k = FirstRow2
i = k - 1
j = RSt.RecordCount + i
Application.ScreenUpdating = False
ThisWorkbook.Sheets("Account Level").Select
Do Until i = j
i = i + 1
With ThisWorkbook.Sheets("Account Level")
.Range(Cells(k, 14), Cells(k, 36)).Copy
.Cells(i, 14).PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.Cells(i, 14) = i - k + 1
.Cells(i, 15) = RSt.Fields("AccountNumber")
.Cells(i, 18) = RSt.Fields("Name")
.Cells(i, 23) = RSt.Fields("Current_Balance")
.Cells(i, 26) = RSt.Fields("Average_Balance")
.Cells(i, 28) = RSt.Fields("Base_Rate") / 100
.Cells(i, 30) = RSt.Fields("Rate_w_Bomus") / 100
.Cells(i, 31).FormulaR1C1 = "=(RC[-1]-RC[-3])/365*30*RC[-5]" 'Interest Variance to Std
.Cells(i, 33).FormulaR1C1 = "=RC[-1]*12" 'Annualized
.Cells(i, 34) = RSt.Fields("Rate_w_Bomus") / 100
.Cells(i, 35).FormulaR1C1 = "=(RC[-1]/365*30)*RC[-9]" 'New Int Var
.Cells(i, 36).FormulaR1C1 = "=RC[-1]*12)" 'New Annualized
End With
Last edited by a moderator: