Excel Runtime Error 91
Contents |
360 games PC games runtime error 91 vba Windows games Windows phone games Entertainment All Entertainment runtime error 91 excel macro Movies & TV Music Business & Education Business Students & educators excel vba runtime error 91 find Developers Sale Sale Find a store Gift cards Products Software & services Windows Office Free downloads & security Internet
Run Time Error 91 Excel Vba
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 run time error 91 excel 2013 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
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta how to fix runtime error 91 object variable not set Discuss the workings and policies of this site About Us Learn more
Run Time Error 91 Vba
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Run-time Error '91' In Excel Macro
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping https://support.microsoft.com/en-us/kb/327245 each other. Join them; it only takes a minute: Sign up What is run time error 91, and why is it showing up in my Excel VBA script? up vote 2 down vote favorite Okay, so I'm trying to write a simple script in VBA for Excel that changes an AutoFilter based on some value the user http://stackoverflow.com/questions/14164950/what-is-run-time-error-91-and-why-is-it-showing-up-in-my-excel-vba-script selects in a cell on the spreadsheet. So far it's been working out pretty well, but now I'm getting the following error and I can't figure out what's causing it: Run-time error '91': Object variable or With block variable not set Keep in mind that this is literally the first time I've ever tried to write anything in VBA so I'm not very familiar with the language. I am very familiar with Excel though and I know several other programming languages (Java, JavaScript, Ruby, LUA). Here's the code I wrote; the error is happening on line 9. Private Sub Worksheet_Change(ByVal Target As Range) '' Review Level Changed '' If Target.Address = Worksheets("Sheet1").Range("review_level").Address Then ' MsgBox "You just changed " & Target.Address & " to " & Target.Value ' Debug Dim oldProtection As Protection If Worksheets("Sheet1").ProtectContents = True Then oldProtection = Worksheets("Sheet1").Protection ' It errors out here Worksheets("Sheet1").Unprotect End If If Target = "B" Then ActiveSheet.ListObjects("review_checklist").Range.AutoFilter Field:=2, _ Criteria1:=Array("B", "C", "D"), Operator:=xlFilterValues ElseIf Target = "C" Then ActiveSheet.ListObjects("review_checklist").Range.AutoFilter Field:=2, _ Criteria1:="=C", Operator:
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 Learn more about Stack Overflow the http://stackoverflow.com/questions/22840227/vba-run-time-error-91-trouble-setting-object-variable company Business Learn more about hiring developers or posting ads with us Stack Overflow http://stackoverflow.com/questions/32094426/run-time-error-91-object-variable-or-with-block-not-set Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack 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 VBA Run time error 91. Trouble setting object variable up vote 0 down vote favorite I don't think the time error answer is too complicated, I must just be missing something basic. To give context, the code and this macro were written by an employee who was no longer working here when I started. I have just used it a number of times on a monthly basis and it suddenly gave me an error today when I attempted to run the VBA script. It gives me the standard Run Time Error 91 (Object variable time error 91 or block variable not set). The code specifically is: Dim DataBook As Workbook Set DataBook = Workbooks.Open(Import_File_Path) DataBook.Worksheets("Sheet1").Name = "Database" Application.DisplayAlerts = False Tool.Worksheets("Database").Delete <-----highlighted error line Application.DisplayAlerts = True DataBook.Worksheets("Database").Move before:=Tool.Worksheets(1) The VBA script is attempting to take raw data from an Excel sheet that I have already generated, and import the file (thus that part in the Set line) and perform a number of calculations to create more data and stats from there. However the problem I feel lies in the section I posted here and the objects and variables. The highlighted error row is the one that says Tool.Worksheets("Database").Delete. When I added a Watch to that row the value states Object Variable or With block variable not set. This leads me to believe something is not being set as it should as an object, but again I am a VBA newbie and I am not confident about any of my gut feelings. For what its worth, I should mention I added another Watch to the line that says DataBook.Worksheets("Sheet1").Name = "Database" and the value for that states Subscript out of range. I thought that meant it could also be a problem, however I am 100% sure there is a tab in the file I am importing that is named Sheet1. excel vba excel-vba runtime-e
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 Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack 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 Run-time error 91: Object variable or With block not set up vote 1 down vote favorite I have a macro that searches and copies some date from one sheet back into another, if that value is found, and repeats for every row that's not blank. In my current document, of around 150 rows, the following macro runs fine, but randomly throws up the error: Run-time error '91': Object variable or With block variable not set This is the macro: Sub Update() Application.ScreenUpdating = False Application.CutCopyMode = False Application.StatusBar = "Cleaning New Roles..." Sheets("new").Select Range("A2").Select Do Until IsEmpty(ActiveCell) Dim SearchValue As String SearchValue = ActiveCell.Value Sheets("Old").Select On Error GoTo Error_handler Cells.Find(What:=SearchValue, SearchOrder:=xlByRows, SearchDirection:=xlNext, SearchFormat:=False).Activate Range("R" & Selection.Row & ":T" & Selection.Row).Select Selection.Copy ActiveCell.Offset(0, -1).Select Sheets("new").Select Range("R" & Selection.Row).Select Selection.PasteSpecial Paste:=xlPasteValues Error_handler: Sheets("new").Select Range("A" & Selection.Row).Select ActiveCell.Offset(1, 0).Select Loop Application.ScreenUpdating = True Application.StatusBar = False End Sub The debug highlights the Cells.Find row. I can't see why the first 100 rows are OK and then it breaks. Any guidance would be very helpful. excel vba excel-vba share|improve this question edited Aug 20 '15 at 14:14 shA.t 8,47641542 asked Aug 19 '15 at 11:37 Tim Wilkinson 93021133 add a comment| 3 Answers 3 active oldest votes up