+ Reply to Thread
Results 1 to 5 of 5

Runtime error 91: Object variable or With block variable not set

  1. #1
    Registered User
    Join Date
    09-26-2019
    Location
    Germany
    MS-Off Ver
    Office 2017
    Posts
    7

    Runtime error 91: Object variable or With block variable not set

    Hello everyone,

    I have a problem with my macro. It always stop on this point (red color):

    Please Login or Register  to view this content.
    How the Code works
    It gets an Array with the Name of the Sheets (Example below) and use it to open it via the function Workbooks.Open, then it will call a function, where the things inside the report will be formatted.

    Please Login or Register  to view this content.

    Error description:
    2019-10-09_7-52-49.png

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Runtime error 91: Object variable or With block variable not set

    Hi
    AT least
    Please Login or Register  to view this content.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Runtime error 91: Object variable or With block variable not set

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Runtime error 91: Object variable or With block variable not set

    Have you tried using ThisWorkbook instead of ActiveWorkbook?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    09-26-2019
    Location
    Germany
    MS-Off Ver
    Office 2017
    Posts
    7

    Re: Runtime error 91: Object variable or With block variable not set

    Hello everyone,

    thanks for all your replies. I tried mohadin`s and bakerman2`s recommendation, but it didnt solve the problem, but after the change from ActiveWorkbook to ThisWorkbook the error message didnt return back

    With best regards,
    John

+ 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. Runtime Error 91 Object variable or with block variable not set
    By pooky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2019, 08:31 AM
  2. [SOLVED] VBA Runtime Error 91: Object variable or With block variable not set.
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-25-2018, 09:15 AM
  3. [SOLVED] Runtime Error 91: Object variable or With block variable not set
    By Andrew.Trevayne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2018, 09:12 AM
  4. Runtime Error 91 - object variable or with block variable not set
    By 0celj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2013, 09:40 PM
  5. runtime error 91 object variable or With block variable not set
    By tullemann in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 01:27 PM
  6. Replies: 8
    Last Post: 02-17-2009, 02:24 PM
  7. Runtime error 91 - Object variable or with block variable not set
    By Christian411 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2008, 08:05 AM

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