As mentioned above, we need to look at the matter in context.
"Not every one who says to me, Lord, Lord,' shall enter the kingdom of heaven, but he who does the will of my Father who is in heaven. On that day many will say to me, Lord, Lord, did we not prophesy in your name, and cast out demons in your name, and do many mighty works in your name?’ And then will I declare to them, `I never knew you; depart from me, you evildoers.’
What is needed to be recognized by Jesus? It is to “Do the will of my Father who is in heaven”. So one must ask what is that will? Jesus tells us very plainly that it is to Love God and to Love neighbor as yourself (Mt 22:36-40). For this reason He leaves with but one command - To Love one another as He loves us (John 13:34-35).
These who claim to act in His name never mention “love” in their defense - not once. They lay claim to great deeds, but Look at what the Holy Spirit tells us through St Paul in 1 Cor 13…
1If I speak in the tongues of men and of angels, but have not love, I am a noisy gong or a clanging cymbal. 2And if I have prophetic powers, and understand all mysteries and all knowledge, and if I have all faith, so as to remove mountains, but have not love, I am nothing. 3If I give away all I have, and if I deliver my body to be burned, but have not love, I gain nothing.
If I prophesy - If I understand mysteries - If I have great faith so as to show great signs…but have not love…
Then Paul goes on to describe what IS God’s will…in Love…
4Love is patient and kind; love is not jealous or boastful; 5it is not arrogant or rude. Love does not insist on its own way; it is not irritable or resentful; 6it does not rejoice at wrong, but rejoices in the right. 7*Love bears all things, believes all things, hopes all things, endures all things.
These are the things lacking in the ones Jesus refers to in Mt 7:23.
This is further emphasized in Mt 25:31-46. Look at what separates the saved from the damned. It is Love…not prophecy or “healing” or other things done “in Jesus name”.
Love is key in all things. It is the one thing that Jesus tells us we need to be perfect in…
Mt 5:
43"You have heard that it was said, ‘You shall love your neighbor and hate your enemy.’ 44But I say to you, Love your enemies and pray for those who persecute you, 45so that you may be sons of your Father who is in heaven; for he makes his sun rise on the evil and on the good, and sends rain on the just and on the unjust. 46For if you love those who love you, what reward have you? Do not even the tax collectors do the same? 47And if you salute only your brethren, what more are you doing than others? Do not even the Gentiles do the same? 48You, therefore, must be perfect, as your heavenly Father is perfect.
Hope this helps you.
Peace
James