locked
On error goto not working RRS feed

  • Question

  • hi all,

    I am using xp office.

    below code is showing error " run time error 91: object variable or with block variable not set.

    On Error GoTo stop1:
    
    start_to_be_copy = ActiveWorkbook.Sheets("Collated cases").Range("a4:a65000").Find(p).Row
    end_of_copy = ActiveWorkbook.Sheets("Collated cases").Range("a4:a65000").Find(p, SearchDirection:=xlPrevious).Row
    
    stop1:



    born to code
    Tuesday, September 6, 2011 3:52 PM

Answers

  • you get an error at compilation level, so 'on error goto' doesn't work.

    the 'row' is an object, not a valuetype variable. so, you must write 'Set' before 'starttobecopy' and 'endofcopy'


    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Marked as answer by Pulsecoding Tuesday, September 6, 2011 4:39 PM
    Tuesday, September 6, 2011 4:09 PM

All replies

  • you get an error at compilation level, so 'on error goto' doesn't work.

    the 'row' is an object, not a valuetype variable. so, you must write 'Set' before 'starttobecopy' and 'endofcopy'


    please, mark this as answer if it is THE answer
    ----------------
    Diego Cattaruzza
    Microsoft MVP - Visual Basic: Development
    blog: http://community.visual-basic.it/Diego
    web site: http://www.visual-basic.it
    • Marked as answer by Pulsecoding Tuesday, September 6, 2011 4:39 PM
    Tuesday, September 6, 2011 4:09 PM
  • Thanks. It's sorted out.
    born to code
    Tuesday, September 6, 2011 4:40 PM