Excel Crashing on one line of code

  • I have a Worksheet Change code, below being the start, however when executing the last line, excel shuts down/closes. 'If Not Intersect(Target, MyRange) is Nothing Then'

    Can anyone see anything wrong with the below code?


    Thanks in advance.

  • Maybe

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Thanks KjBox. I was playing around with it and changed the code below and its no longer crashing. No idea why you'd need to say what sheet the range is on as you have to be on the same sheet when runng a worksheet change macro..

    Thanks though, if I have any other issues I'll try your code.


    Code
    Set MyRange = Range("B14:B1048576") changed to 
    Set MyRange = sheet1.Range("B14:B1048576")
  • If you have another sheet active and a change on that active sheet causes Sheet1 Column B to change then yes, you will have to specify the Sheet

    We now have a reputation system in place. If my reply helped please "Like" the reply by clicking the "Like" icon at bottom right of my reply.

  • Assuming Sheet1 is the sheet with the change event in it, there is no technical difference between the original code and the code with the sheet specified, so I don't see why it would have fixed anything to be honest.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

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