Hi. I have been using excel macro as below and experiencing "Runtime error 9: Subscript out of range" error. It happens only when I use a variable to reference a worksheet within a workbook.
I am trying to activate a window that I have just opened. My code is as follows:
Dim quarter As Integer
Dim yr As Integer
yr = InputBox("Enter the year:", "Year")
quarter = InputBox("Enter the quarter (just the number):", "Quarter")
If quarter <> 1 Then...
Hi,
Disclaimer: I am using Excel 365 and I have zero programming knowledge or experience.
Today I used Macros for the first time and recorded a Macro to pull bank fixed deposit rates from a bank website and input data from this table to another one.
But when I run this Macro, I get a Runtime...
Hello. So I have this VBA code to identify two open workbooks and match data across them. One is Routing. One is Pickorder. This one is a unique name daily but always has PickOrder in it along with the current date. When this code is run a third workbook is open (not part of code). However when...
Hello,
Let me start by saying that I am very new to VBA coding, so I'm sure I am making a simple mistake. I found similar questions to this on the forum, but none had exactly what I'm looking for.
I have a document that is updated daily to track certain progress in my work team. I have...
I keep getting a subscript out of range error when I run this code
Private Sub CommandButton1_Click()
Dim file_path As String
Dim xlApp As Excel.Application
Set xlApp = CreateObject("Excel.Application")
file_path = FileSelectBox("*.xlsx")
xlApp.Visible = True
'xlApp.Workbooks.Open...
Hi,
Im writing some code to calculate daily, monthly and annual realised volatlity. ( I know i can do this with stdev but for what i want to use it for i want a manual calc.)
I keep getting "subscript out of range" error once it goes beyond my last cell in the monthly calcluation
Any ideas...
Hello all,
I am trying to import data from a network file to update a dashboard. My VBA retreives the data a brings it into a new workbook but then when my code attempts to copy and paste in into my forecasting model i receive a runtime error 9 "subscript out of range".
I want to declare the...
I am trying to set an open workbook as variable book2 but keep getting a 'Subscript out of range' error. Below is the code I am working with. It errors at 'Set book2'. It's completely random and will work sometimes but most of the time it doesn't. Could someone help?
Set book1 = ActiveWorkbook...
Hi Team Amazing,
I need some help.
I have a sub that allows users to select a workbook and then open it. I then prompt them to select the tab that contains the data required.
I then want to copy all of the data from this tab and paste it into the workbook where the Sub is located...
Happy sunday everybody!
I am new to vba and I am trying to create a deck of 40 cards (mazzo2), with suits (seme) and values (valore):
Function NtoCarta40() As String
Dim seme(1 To 40) As String, valore(1 To 40) As Long, i As Long, mazzo2(1 To 40) As String
For i = 1 To 40
Select Case i...
Thank you for your time. I am a real beginner in the VBA and I am asking for your help for the next issue.
I have
A sheet called "START" in which an ActiveX ComboBox named ”CLIENTI” is inserted,
and
A sheet called "CLIENT" in which the Range ”B3:B100” contain hyperlink addresses to various...
Hello,
I have a piece of code designed to place horizontal page breaks so the heading for a group of data isn't by itself at the bottom of a page. However, it throws a run-time error 9 - subscript out of range.
This appears to be a known issue, but Microsoft's solution, to select the last cell...
Hi,
I am getting a script out of range error message.
I am trying to look up the text in cell B4 on Sheet “Specs.” My table array is a named range call “ContinueWithTask”. ContinueWithTask is columns A:X on a sheet called “Task Names”.
If the vlookup finds the cells is empty, I want it...
Good Afternoon, been racking my brain on this one for awhile and cannot figure it out. I keep getting a subscript out of range on the second line of code listed below. When I run this code on a regular table it works great, but when ran on a pivot table it wont work. Any help would be greatly...
Hey all,
I'm working on this code but everytime I run it, I get a subscript error on the .Value lines. I don't know what I'm doing wrong.
Private Sub ComboBox2_Change()
Range("F3:PO3").Clear
Dim SDates() As String
Dim CDates As String
Dim c As Range
Select Case ComboBox2
Case Is =...
Hello All,
I am trying to select sheets to generate a PDF by using a UserForm with checkboxes so the user can select which sheets he/she wants generated into a PDF. Below is my code and I feel as if I am close but I continue to get a "Run-time error '9': Subscript out of range" at the...
Hello All,
I am trying to select sheets to generate a PDF by using a UserForm with checkboxes so the user can select which sheets he/she wants generated into a PDF. There are 2 sheets "Cover" and "PP" that must be included anytime a user wants to generate a PDF. Below is my code and I feel as...
Hello All,
I am new VBA and Macros. I am trying to open a workbook and if it is already open just activating that workbook. But I am getting "Subscript out of Range" error again. Below is the snippet of my code.
Sub Activating()
Dim DestFile As String
Dim wb As Workbook
DestFile =...
Hi,
I am trying to create a macro that copies and pastes all the data from one tab in a closed workbook into an open and active one. Two main considerations: the name of the source file changes every day and the amount of data with vary each day (some days one line of data, other times...
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.