In this sentence should I use "he" in place of 'him"?
He explained that Lily, not him, had planned the party.
In formal and scholastic registers, "he" is appropriate. It is part of the subject of the subordinate clause.
The alternatives presented here are that Lily had planned the party and that he had planned the party. The complete subject of the clause is "Lily [and] not he", which excludes the latter alternative.
That being said, the informal registers of many English dialects are not exclusively subject-oriented. For the same reason that the formal "it is I" is often replaced by the common "that's me", the appositive "not him" can easily take the oblique case -- not as an object but merely as a non-topic.
We don't commonly regard English as a topic-oriented language. Still, we can't explain how the informal variants of copular clauses (such as "that's me") and interrogative clauses (such as "who did you see?") function under a purely subject-oriented framework.
Given the clause (what was explained):
Lily, not him, had planned the party.
both Lily and "him" are subjects. So use the subjective pronoun form, he is correct:
He explained that Lily, not he, had planned the party.
But in informal speech, people often say it either way, often depending on what seems to sound best.
Both "he" and "him" are awkward.
This sentence falls into a broad class of sentences in which a pronoun is used as part of a subject, but isn't the whole subject. The most well known example of this type of sentence is:
John and me planned the party.
or
John and I planned the party.
Both may be considered correct, as both are used commonly by native speakers. The second sentence is correct in "prescriptive grammar", as the word "I" is in the subject, and so the nominative case should be used.
There is an alternate rule, which states that "I" should only be used when it forms the whole subject, and as it is not the whole subject, the correct pronoun should be "me".
In your example, application of the first rule leads to "not he", the second rule would lead to "not him". However both are awkward
Rephrasing would be a much better alternative.
He explained that Lily had planned the party; he had nothing to do with it.
Other people have already told you the correct answer (it's "he" according to the strict rules of English, but that sentence sounds a little awkward to native speakers). So instead, I'm going to focus on something that only one person has mentioned in a comment, which is a general rule for figuring out the right pronoun in sentences like this one.
A good way to decide between "he" and "him" (or "she" and "her") in sentences like "John and (I/me) went to the party" or "Lily, not (he/him), had planned the party" is to remove the extra subject. Leave the pronoun alone in the sentence and see what it should be. Consider these two sentences:
I went to the party.
or
Me went to the party.
When you look at them like that, it becomes clear that the correct pronoun is "I", therefore the correct sentence is
John and I went to the party.
This general rule will help you figure out the pronoun in other situations too, like when the pronoun is the object, rather than the subject, of the verb. For example:
My friends bought movie tickets for my wife and (I/me).
Which one should it be? Well, remove the extra object and that sentence becomes:
My friends bought movie tickets for (I/me).
And now it's clear that the right pronoun is "me", so the correct sentence is:
My friends bought movie tickets for my wife and me.
NOTE: This particular example ("for my wife and me") is one that many native speakers of English get wrong. There's also some dispute about whether it's really "wrong" or not, but that's a question that you probably don't need to worry about as a second-language learner. Just remember the general rule (remove the other words to figure out what the pronoun would be if it was alone), and you'll get it right.
you should use he in this case. because here in the sentence Lily is the subject who does the action so you have to use a subject pronoun you can not use the object pronoun.
He explained that Lily, not him, had planned the party.
You'll need to use 'he' if the personal pronoun refers to the subject of the sentence. You'll need to use 'him', if the personal pronoun refers to the object. I guess in that case the subject is Lily so 'him' is correct.
Note: I am neither a native speaker nor an expert - I am just trying to help.