+ Reply to Thread
Results 1 to 9 of 9

fixing run time error 91 object variable or with block variable not set

  1. #1
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    fixing run time error 91 object variable or with block variable not set

    hello
    i need help fixing this code i try copy data from sheet to another based on criteria
    the error in this line
    HTML Code: 
    HTML Code: 
    thanks
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: fixing run time error 91 object variable or with block variable not set

    Other than changing:
    rngC.Offset(, -6) '! 6 to 5
    And
    Please Login or Register  to view this content.
    your code works...Not sure why you are looking for last column in loop if you are only copying A to F
    Please Login or Register  to view this content.

    Another option...


    Please Login or Register  to view this content.
    Last edited by sintek; 09-07-2020 at 05:40 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,482

    Re: fixing run time error 91 object variable or with block variable not set

    If you are in column F, you can't offset(,-6) columns, that will take you off the sheet.
    Try it, select F1 and then move to the left 6 times.

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: fixing run time error 91 object variable or with block variable not set

    Also...that code does not produce that error?

  5. #5
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: fixing run time error 91 object variable or with block variable not set

    thanks daves for your notice

  6. #6
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: fixing run time error 91 object variable or with block variable not set

    thanks sintek you give me verity codes are great and for correcting my code works so well but i have two thing if is possible whether my code or your i don't copy repeatedly data just if i have a new data then copy to bottom old data and how i can delete the copied data from source sheet"data"

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: fixing run time error 91 object variable or with block variable not set

    Please Login or Register  to view this content.

    If you really want to loop then....

    Please Login or Register  to view this content.
    Last edited by sintek; 09-07-2020 at 06:16 AM.

  8. #8
    Forum Contributor
    Join Date
    06-02-2019
    Location
    libya
    MS-Off Ver
    2010
    Posts
    734

    Re: fixing run time error 91 object variable or with block variable not set

    well done ! sintek thanks for your time

  9. #9
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: fixing run time error 91 object variable or with block variable not set

    All good...

+ 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: 12
    Last Post: 12-28-2019, 12:29 PM
  2. [SOLVED] Run time error '91' object variable/with block variable not set when using Find
    By lynnsong986 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-24-2019, 08:33 AM
  3. [SOLVED] Run-time error '91': Object variable or With block variable not set when closing userform
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2016, 08:59 AM
  4. Replies: 0
    Last Post: 04-16-2013, 07:15 AM
  5. Replies: 6
    Last Post: 12-21-2012, 08:03 AM
  6. Replies: 1
    Last Post: 09-25-2012, 08:03 PM
  7. [SOLVED] Intermittent Run-time Error 91: Object Variable or With Block variable not set
    By fraanchtoast in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-29-2012, 10:11 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