+ Reply to Thread
Results 1 to 14 of 14

Run-time error 91 - Object variable or with block variable not set

  1. #1
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Run-time error 91 - Object variable or with block variable not set

    Hello -

    I received a snippet of code today that works fine by itself - but then I try to combine it into the whole project I get the '
    run-time error 91. Highlighted in red is the code I received today...and in bold is where the run-time error is occurring
    (.Formula line)

    Thanks,

    Please Login or Register  to view this content.

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

    Re: Run-time error 91 - Object variable or with block variable not set

    If there's no data in column M of the active sheet you will get the error you describe.


    Is the sheet you want to run that piece of code on active?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    Not sure - I think I tried to actvate that sheet but was getting the same error.

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

    Re: Run-time error 91 - Object variable or with block variable not set

    What sheet should the code be run on?

    Whatever it is try replacing ActiveSheet with an explicit reference to it.

  5. #5
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    It should be run on sheet 1...should it be something like this:

    Please Login or Register  to view this content.

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

    Re: Run-time error 91 - Object variable or with block variable not set

    If the worksheet the code is to run on has the codename Sheet1 that code should work.

  7. #7
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    Hello - seem to be struggling with this. I have changed the code to this:

    Please Login or Register  to view this content.

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

    Re: Run-time error 91 - Object variable or with block variable not set

    Why did you change it to that?

    That code won't work for a number of reasons.

    Did substituting Sheet1 for ActiveSheet not work?

  9. #9
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    I did it based on somethign I did in another sub...i changed it back to the below and get the same error 91:

    Please Login or Register  to view this content.

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

    Re: Run-time error 91 - Object variable or with block variable not set

    What's the name of the worksheet?

    Can you attach a sample workbook?

  11. #11
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    Sure - here you go:


    Column F should be the new column E after running macro.

    Thanks
    Attached Files Attached Files

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

    Re: Run-time error 91 - Object variable or with block variable not set

    This line of code is looking for data in column M, not E or F.
    Please Login or Register  to view this content.
    In the workbook you attached there's no data in column M.

  13. #13
    Forum Contributor
    Join Date
    11-06-2012
    Location
    New Jersey, US
    MS-Off Ver
    Excel 2016
    Posts
    182

    Re: Run-time error 91 - Object variable or with block variable not set

    Ok...can you take a look at this file which works...it's essentially the same code as
    the other file

    Thanks
    Attached Files Attached Files

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

    Re: Run-time error 91 - Object variable or with block variable not set

    Is there a problem with the file?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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