RTE 9 Subscript out of range

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,756
Office Version
  1. 2007
Platform
  1. Windows
Morning.
I have a sheet called MILEAGE (1)
I have c ommamd button with the following code shown below.
When i run the command button code i see a Msgbox saying RTE 9 Subscript out of range.
When i debug i see the line should below in Yellow

Rich (BB code):
Private Sub CommandButton2_Click()
Dim answer As Long, wb As Workbook
    answer = MsgBox("ONLY TRANSFER FIGURES IF ITS THE END OF THE MONTH" & vbNewLine & "" & vbNewLine & "***** DO WE CONTINUE TO TRANSFER THE FIGURES ? *****", vbYesNo + vbCritical, "END OF MONTH TRANSFER QUESTION")
    If answer = vbYes Then
        Set wb = Workbooks.Open(FileName:="C:\Users\Ian\Desktop\EBAY\ACCOUNTS\CURRENT SHEETS\SUMMARY SHEET 2024-2025.xlsm")
        
        Workbooks("ACCOUNTS.xlsm").Sheets("MILEAGE (1)").Range("C32").Copy
        wb.Sheets("SUMMARY SHEET").Range("I17").PasteSpecial xlPasteValues
        wb.Close True

        Else
        Exit Sub
        
        End If
        Workbooks("ACCOUNTS.xlsm").Sheets("MILEAGE (1)").Range("A2").Select
        Application.CutCopyMode = False
        MsgBox "SUMMARY TRANSFER COMPLETE", vbInformation, "SUCCESSFUL MESSAGE"
        Sheets("SUMMARY ACCOUNTS").Select
        ActiveWorkbook.Save
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
I have checked the spelling of MILEAGE (1)
I also changed it to MILEAGE

But it still shows the message.

The code opens the SUMMARY SHEET & then i see the Message
 
Upvote 0
That error on the red line of code would indicate no open workbook called "ACCOUNTS.xlsm" (unlikely given the previous line opens it) or if there is an open workbook with that name then it does not contain a worksheet called "MILEAGE (1)"
 
Last edited:
Upvote 0
Solution
You are spot on many thanks.
I was testing out some new code & had renamed the original file ACCOUNTS TEST
Didnt even consider that.

Have a nice day.
 
Upvote 0

Forum statistics

Threads
1,223,993
Messages
6,175,844
Members
452,675
Latest member
duongtruc1610

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