Object Variable or With Block Variable not set. Quite confused here.:(

  • Hi to all of you,


    Could anyone please direct me in the right direction and tell me what is wrong with my code. It does not work. Feel free to call me an idiot.! LOL



    Any help would be most welcome,


    Thanks.

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Cells A2 and A10 can never intersect so Intersect(Range("A2"), Range("A10")) will return Nothing.


    What are you trying to do?

    Boo!:yikes:

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Thanks for the quick reply, Flash. I mean, norie.


    Wow, I am an idiot! You are correct!


    Quote

    What are you trying to do?


    In Column A2:A10 if any of those cells value changes either Hide or Show Userform1. Values in that range are already in place and depending which value was selected respond accordingly.

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Not 100% sure what you are doing but if you want the code to run when a change is made in A2:A10 try this.

    Boo!:yikes:

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Thanks for the quick reply, Flash. I mean, norie.


    Wow, I am an idiot! You are correct!


    Quote

    What are you trying to do?


    In Column A2:A10 if any of those cells value changes either Hide or Show Userform1. Values in that range are already in place and depending which value was selected respond accordingly.


    I have changed your code in post no. 4 to,



    And now it seems to work as I want.


    Thank you norie!

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    Hi norie,


    Haste makes waste.


    Quote

    What are you trying to do?


    Quote

    And now it seems to work as I want.


    But I was wrong. Please could you help me with the correct syntax to Exit the Sub if the cursor is not within the Range A2:A10?



    Thank you norie!

  • Re: Object Variable or With Block Variable not set. Quite confused here.:(


    If the changed cell is not in the range A2:A10 this, existing, code tells VBA to exit the sub.

    Code
    If Not Application.Intersect(Target, Range("A2:A10")) Is Nothing Then Exit Sub

    Boo!:yikes:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!