Excel Run Time Error 9
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
Excel Runtime Error 9 Subscript Out Of Range
Learn more about Stack Overflow the company Business Learn more about hiring developers runtime error 9 excel vba or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack what does runtime error 9 mean Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up macro run-time error '9': subscript out of
Macro Run Time Error 13
range up vote 1 down vote favorite I found a macro on the web to protect a worksheet with a password. It works fine, but when I save the file I get the message: run-time error '9': subscription out of range. I have never programmed or used visual basic before and could use some help . Thank you The macro is: Private Sub Workbook_BeforeClose(Cancel As Boolean) 'Step
Excel 2007 Runtime Error
1:Protect the sheet with a password Sheets("Sheet1").protect Password:="btfd" 'Step 2: Save the workbook ActiveWorkbook.Save End Sub excel excel-vba share|improve this question edited Feb 20 '14 at 22:07 simoco 26.7k93552 asked Feb 20 '14 at 22:06 user3334808 6112 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote "Subscript out of range" indicates that you've tried to access an element from a collection that doesn't exist. Is there a "Sheet1" in your workbook? If not, you'll need to change that to the name of the worksheet you want to protect. share|improve this answer answered Feb 20 '14 at 22:10 The Dark Canuck 1367 add a comment| Did you find this question interesting? Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Subscribed! Success! Please click the link in the confirmation email to activate your subscription. up vote 1 down vote Why are you using a macro? Excel has Password Protection built-in. When you select File/Save As... there should be a Tools button by the Save button, click it then "General Options" where you can enter a "Password to Open" and a "Password to Modify
360 games PC games excel runtime error 5 Windows games Windows phone games Entertainment All Entertainment
Excel Runtime Error 53
Movies & TV Music Business & Education Business Students & educators excel runtime error 429 Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet http://stackoverflow.com/questions/21920697/macro-run-time-error-9-subscript-out-of-range Explorer Microsoft Edge Skype OneNote OneDrive Microsoft Health MSN Bing Microsoft Groove Microsoft Movies & TV Devices & Xbox All Microsoft devices Microsoft Surface All Windows PCs & tablets PC accessories Xbox & games Microsoft Lumia All https://support.microsoft.com/en-us/kb/210663 Windows phones Microsoft HoloLens For business Cloud Platform Microsoft Azure Microsoft Dynamics Windows for business Office for business Skype for business Surface for business Enterprise solutions Small business solutions Find a solutions provider Volume Licensing For developers & IT pros Develop Windows apps Microsoft Azure MSDN TechNet Visual Studio For students & educators Office for students OneNote in classroom Shop PCs & tablets perfect for students Microsoft in Education Support Sign in Cart Cart Javascript is disabled Please enable javascript and refresh the page Cookies are disabled Please enable cookies and refresh the page CV: {{ getCv() }} English (United States) Terms of use Privacy & cookies Trademarks © 2016 Microsoft
your Excel programming skills need a boost? Are you wasting valuable time when you write and troubleshoot your code? Get expert training at the Excel VBA Master Class that will be held in Amsterdam, on October 26-27. This two-day course, led by http://www.contextures.com/excelvbatips.html Jan Karel Pieterse and Tony de Jonker, should quickly pay for itself, in the time that you'll save on your VBA projects. Error Message Debug Button F8 Key Stops Working Project Explorer Folders Missing More Tutorials Error Message Debug http://www.ozgrid.com/forum/showthread.php?t=172384 Button Occasionally, when you try to run a macro, an error message will appear, such as the "Run-Time Error '9'" Subscript Out of Range" error shown below. On this error message, there are 3 buttons available -- End, Debug time error and Help. To stop the macro, click the End button. To get information about the error, click Help. In this case, you would end up on page on the Microsoft website, with a list of possible causes and solutions for the Subscript Out of Range error. To go to the VBE and try to solve the problem, click the Debug button. Debug the Macro In this example, a macro was recorded, to go to a sheet named "Main", then time error 9 select cell C3 on that sheet. When the macro is run, the above error message appears. Here is the VBA code, for the GoToMainSheet macro: Sub GoToMainSheet() ' GoToMainSheet Macro Sheets("Main").Select Range("C3").Select End Sub We'll use the Debug button, to troubleshoot the problem: In the error message, click the Debug button The VBE opens, showing the GoToMain Sheet macro, and a line of code is highlighted in yellow, with a yellow arrow n the margin at the left. Excel showed the error message, because it can't complete the highlighted line of code. Look in the Project Explorer window, and check the list of sheets for the active workbook. There are 3 sheets, named "Intro", "Sheet2" and "Sheet3" -- there isn't a sheet named "Main" We'll stop the debugger, and fix the code. On the VBE Toolbar, click the Reset button The code stops running, and the yellow highlighting disappears. Fix the Code Next, you'll edit the code, to change the sheet name. Solution 1: Not Recommended In the line of code, you could replace "Main" with "Intro", which is the current name of the first sheet in the workbook. However, with that solution, the code could show an error again, if anyone changes the sheet name in the future. Sheets("Intro").Select This is not the best solution Solution 2: Recommended Instead of using the name from the Sheet tab, we'll use the sheet's Code Name
Way | Trading Add-ins For Excel | Convert Excel Into Calculating Web Pages Excel Web Pages | Produce Clean Efficient VBA Code Every Time | Build Automated Trading Models In Excel | Excel Web Pages | Excel Video Training Forum New Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links Today's Posts What's New? Advanced Search Forum HELP FORUMS Excel General Run-time error 9 (subscript out of range) when running macro to copy table Excel Training / Excel Dashboards Reports If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. If you don't like Google AdSense in the posts, register or log in above. Click here to view the relaunched Ozgrid newsletter. Results 1 to 5 of 5 Thread: Run-time error 9 (subscript out of range) when running macro to copy table Thread Tools Show Printable Version Search Thread Advanced Search December 1st, 2012 #1 Greta View Profile View Forum Posts I agreed to these rules Join Date 1st December 2012 Posts 2 Run-time error 9 (subscript out of range) when running macro to copy table Hello, I'm trying to create a macro in a "home" worksheet that will open another worksheet ("source"), copy its table of data (the # of rows in the table will vary, but the # of columns probably will not), and paste it in the home WS, and then close the source worksheet. The home WS will eventually be expanded to include manipulation of the data, but for now I can't get it to perform the simple operation in the previous sentence without the error message. Here's the VB code: VB: ' Macro1 Macro ' ' ActiveCell.Offset(4, 1).Range("A1").Select ChDir "C:\Documents and Settings\mainman\My Documents\Documents" Workbooks.Open Filename:= _ "C:\Documents and Settings\mainman\My Documents\Documents\West L.A. Home Price Table no 2.xls" ActiveCell.Offset(4, 0).Range("A1").Select Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select S