Jesus said they could not dwell with Him,because they were workers of iniquity not doing the will of the Father,which the Bible says they have a form of godliness;but deny the power thereof,lover of pleasures more than lovers of God,ever learning but never able to come to the knowledge of the truth,that they have to abstain from sin acting like Christ.
2Ti 2:19 Nevertheless the foundation of God standeth sure, having this seal, The Lord knoweth them that are his. And, Let every one that nameth the name of Christ depart from iniquity.
They said Lord,Lord,but could not dwell with Jesus,for they were workers of iniquity,which whoever shall call upon the name of the Lord shall be saved,but there is a condition with that,for whoever calls upon the name of the Lord has to depart from iniquity.
Not all people that call on the name of the Lord depart from iniquity,and that is part of calling on the name of the Lord,to depart from iniquity.
Now this not departing from iniquity does not mean a person that has been saved that might sin once in a while,for a person that has been saved knows that it is wrong to engage in sin,so they will not hold unto a sin,but do it and let is go,but these people that were workers of iniquity held unto sins,and only repented of them when they did them,but would not let the sins go,thinking they were right with God despite holding unto sin,with the excuse we are only human so we cannot abstain from sin,or sin does not affect their relationship with God.