Run-time error '424' : Object required

  • Any idea why i am getting a run time error with the code shown below. I f i hit debug the colum "If Target.column = 21 Then" is highlighted. Basically I am just trying to delete a row if Yes is in column 24 and if yes is in column 21 then i want the row moved to another spreadsheet. Everything works and the code does what i want, i just get this pesky run time error that pops up anyway. Thanks very much!


    ***********************************************************************************************************************************

  • Please add code tags in future as per forum rules.


    After the first block runs you delete Target so it no longer exists and hence the error as you cannot access the column property of a non-existent range. Move the deletion to the end.


    A bit of general advice - learn to indent your code, makes it much more readable.

  • Thanks for your response. However moving the delete entire row code for target.column=24 creates the same runtime error now with the debug column "If Target.column = 24 Then" highlighted rather than 21 as in my previous post.

  • I'll have to look at this tomorrow.


    As an aside, in your loop should it be "r" being deleted rather than Target?


    Going back to basics if Target consists of more than one cell you should loop through to check the intersect with columns 21/24. If Target should only be one cell you should add a line to otherwise exit the sub.

  • Target should be if one cell in the specified target column is "Yes" then carry out the code.
    I tried adding If Intersect(Target, Range("U:U, X:X"")) Is Nothing Then Exit Sub. "U" being for target column 21 and "X" being for target column 24 but that didn't help. Is this what you were referring to above?
    Thanks for the help it is much appreciated.

  • OK, try this. I'm assuming this is a Worksheet Change event.

Participate now!

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