Excel 2003 Vba Run Time Error 91
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 Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Run Time Error 91 Excel
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a run-time error '91' in excel macro community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up simple vba code gives me run
How To Fix Runtime Error 91 Object Variable Not Set
time error 91 object variable or with block not set up vote 15 down vote favorite So I have a simple little macro/sub defined when a command button is clicked. The problem is it gives me: Run Time Error '91' : Object Variable or object variable or with block variable not set vba With Block not Set My code is: Dim rng As Range rng = Sheet8.Range("A12") '<< ERROR here rng.Value2 = "1" I just want to set Cell "A12" in Sheet8. Thanks! excel vba excel-vba excel-2007 share|improve this question edited Jul 10 '14 at 13:00 Fionnuala 77.1k665110 asked Mar 12 '11 at 9:44 gideon 15k54893 I'm sure there is a Sheet8 and there is certainly a cell A12 the sheet. Maybe its the syntax? Should it be "A" and "12" separately? –gideon Mar 12 '11 at 9:49 add a runtime error 91 windows 7 comment| 1 Answer 1 active oldest votes up vote 23 down vote accepted You need Set with objects: Set rng = Sheet8.Range("A12") Sheet8 is fine. Sheet1.[a1] share|improve this answer answered Mar 12 '11 at 9:53 Fionnuala 77.1k665110 +1 thanks doesn't gimme an error but doesn't set the A12 Cell value either? Should it be rng.Value or rng.Formula doesn't work either? –gideon Mar 12 '11 at 9:58 lol! ok now Set rng.Value2 = "1" Gives me a runtime error 424 –gideon Mar 12 '11 at 10:00 @giddy I am back :) You only use Set to set a variable to an object. The code you posted works fine for me with the addition of Set, as per my answer. Does Sheet8 exist? Do not forget I can rename Sheet3 as Sheet8 but it is still Sheet3. Do not confuse the object Sheet8 with the sheet named Sheet8. –Fionnuala Mar 12 '11 at 14:18 BTW You do not need quotes for numbers, but that has nothing to do with the problem. –Fionnuala Mar 12 '11 at 14:19 @Remou aha! So it works at my home machine! And i see I can add an excel form control and an ActiveX Button but it works with both! I guess I probably did something silly at the work machine! Thanks so much! =D –gideon Mar 12 '11 at 14:27 | show 1 more comment Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Em
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Object Variable Or With Block Variable Not Set Vb6 Error
Meta Discuss the workings and policies of this site About Us object variable or with block variable not set excel 2010 Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
Object Variable Or With Block Variable Not Set Access 2010
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 http://stackoverflow.com/questions/5281759/simple-vba-code-gives-me-run-time-error-91-object-variable-or-with-block-not-set 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 answer is too complicated, I must just be missing something basic. To give context, the code and this macro were written by an employee http://stackoverflow.com/questions/22840227/vba-run-time-error-91-trouble-setting-object-variable 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 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 bl
Way | Trading Add-ins For Excel | Convert Excel Into Calculating Web Pages Excel Web Pages | Produce Clean http://www.ozgrid.com/forum/showthread.php?t=62771 Efficient VBA Code Every Time | Build Automated Trading Models In Excel | Excel Web Pages | Excel Video Training Forum New Posts FAQ Calendar Forum Actions http://www.mrexcel.com/forum/excel-questions/617372-intermittent-visual-basic-applications-run-time-error-91-excel-2003-macro-windows-xp-ie-8-0-a.html Mark Forums Read Quick Links Today's Posts What's New? Advanced Search Forum HELP FORUMS Excel General Run Time Error 91, Object Variable or With Block Variable not set time error 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. variable not set 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 8 of 8 Thread: Run Time Error 91, Object Variable or With Block Variable not set Thread Tools Show Printable Version Search Thread Advanced Search January 14th, 2007 #1 PeterLar View Profile View Forum Posts Senior Member Join Date 1st September 2006 Location Maple< Ontario, Canada Posts 105 Run Time Error 91, Object Variable or With Block Variable not set Using Aaron Blood's Kickbutt VBA Find Function, which is pretty amazing in itself VB: Function Find_Range(Find_Item As Variant, _ Search_Range As Range, _ Optional LookIn As Variant, _ Optional LookAt As Variant, _ Optional MatchCase As Boolean) As Range Dim c As Range If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole If IsMissing(MatchCase) Then MatchCase = False With Search_Range Set c = .Find( _ What:=Find_Item, _ LookIn:=LookIn, _ LookAt:=LookAt, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=
Forums Excel Questions Intermittent VBA Run-Time Error 91 in Excel 2003 Macro/Windows XP/IE 8.0 Results 1 to 3 of 3 Intermittent VBA Run-Time Error 91 in Excel 2003 Macro/Windows XP/IE 8.0This is a discussion on Intermittent VBA Run-Time Error 91 in Excel 2003 Macro/Windows XP/IE 8.0 within the Excel Questions forums, part of the Question Forums category; Hi All, I have looked for a day and a 1/2 and googled, read and experimented far and wide but ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Feb 28th, 2012,08:49 PM #1 tdh777 Board Regular Join Date Feb 2012 Posts 89 Intermittent VBA Run-Time Error 91 in Excel 2003 Macro/Windows XP/IE 8.0 Hi All, I have looked for a day and a 1/2 and googled, read and experimented far and wide but am unable to sovle this problem. I have a VBA routine in Excel that automates logging into a website as follows :
Sub Mysub()
Dim ie As Object
Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
base_url = "https://www.somesite.com/"
ie.navigate base_url & "displayLogon.do?o=p&client=somename"
While ie.Busy
DoEvents
Wend
ie.document.getElementById("loginID").value = "my Login"
ie.document.getElementById("accessCode").value = "my Password"
ie.document.forms(0).submit
'trying early binding to see if that helps - same problem
'Dim ieObj As HTMLInputElement
'With ie
' Set ieObj = .document.getElementById("loginID")
' ieObj.Value = "my Login"
' Set ieObj = .document.getElementById("accessCode")
' ieObj.Value = "my Password"
' .document.Forms(0).submit
'End With
While ie.Busy
DoEvents
Wend
Exit Sub