“Item cannot be found in the collection corresponding to the requested name or ordinal” - Error

scanpj10

New Member
Joined
Feb 1, 2013
Messages
13
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:

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Where is the code that populates the Recordset?
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top