You're obviously reading more into that passage than it says.
Even the demons Jesus cast out said He was the Holy One of Israel. Identifying Him correctly doesn't ensure salvation.
It also doesn't say those people confessed His name or that they works in the gifts of the Spirit.
It just says that they said *Lord, Lord* and appealed to mighty works, which the enemy can mimic.
.
No I quote exactly what it says.
Matthew 7:
[21] Not every one that saith unto me, Lord, Lord, shall enter into the kingdom of heaven; but he that doeth the will of my Father which is in heaven.
[22] Many will say to me in that day, Lord, Lord, have we not prophesied in thy name? and in thy name have cast out devils? and in thy name done many wonderful works?
[23] And then will I profess unto them, I never knew you: depart from me, ye that work iniquity.
[24] Therefore whosoever heareth these sayings of mine, and doeth them, I will liken him unto a wise man, which built his house upon a rock:
[25] And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell not: for it was founded upon a rock.
[26] And every one that heareth these sayings of mine, and doeth them not, shall be likened unto a foolish man, which built his house upon the sand:
[27] And the rain descended, and the floods came, and the winds blew, and beat upon that house; and it fell: and great was the fall of it.
Who are they that work iniquity?
Working Iniquity is by definition teaching that we not obey Torah.
Do you know anyone here that does that?
Could Matthew 7 have been specifically written to you?
.