+ Reply to Thread
Results 1 to 4 of 4

Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"

  1. #1
    Registered User
    Join Date
    02-03-2017
    Location
    SE Texas
    MS-Off Ver
    2013
    Posts
    98

    Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"

    My problem has changed to getting a "Compile Error" on this line after adding the "Set" statement:

    "Set qstart = Worksheets"

    and without "Set", I get "Error 91 Object Variable or With Block not defined". Been on this one for better part of two days now.

    If not a solution, I could use some suggestions

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"

    So
    • you only use the "Set" syntax with objects. .Row isn't an object, just a variable. No "Set" needed
    • your syntax is incorrect for hiding the rows. it should be .Rows(qstart & ":" & qend)
    • your not accounting for if "IND" is not found but we can deal with that later
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"

    Set is how you set up object variable. If you use the set with out declaring a variable as object, you get an error, as non object variable could not be set againt a set which is an object. So, declare your variables as objects, like range, worksheet, workbook and use the set word to set up the object variable. In short, set is used with objects.

  4. #4
    Registered User
    Join Date
    02-03-2017
    Location
    SE Texas
    MS-Off Ver
    2013
    Posts
    98

    Re: Choice between "Compile Error" and "Error 91 - Object Variable Not Defined"

    I managed to get things to work really well once I found the problem and was moving on to the next phase of my workbook.. wrapping the main subroutine (and its two called subs) into one. Stay tuned! Thanks, again, for taking the time! (And you were right, by the way.)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 4
    Last Post: 11-13-2015, 09:03 PM
  2. [SOLVED] Frequently Used Macro now Giving a" Runtime Error '1004 Application-Object Defined Error"
    By rjw524 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2015, 02:39 PM
  3. Replies: 1
    Last Post: 05-06-2013, 06:07 AM
  4. [SOLVED] emptyRow code giving Compile Error "Variable not defined"
    By colvinb in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-21-2012, 04:34 AM
  5. Error msgs: "Object varible or with block variable not set"; "subscript out of range"
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-26-2009, 04:58 PM
  6. Error message: "Compile error. User-defined type not defined"
    By lottesfog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2007, 06:38 PM
  7. [SOLVED] What is Error "Method "Paste" of object "_Worksheet" failed?
    By vat in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-17-2006, 04:10 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1