If it was his intention to do the actions and say the words of consecration correctly and completely, then it was consecrated, even if he ‘spaced out’ and accidentally lifted the chalice instead of the host.
It was probably pretty awkward because he was trying to figure out how to make up for it. I was at a mass where the Monsignor (with advanced degrees in theology, very gifted and faithful priest) forgot a line in the Eucharistic prayer. He admitted it at the end of the mass, but assured us that he had added it in silently at a pause, even though it was out of order at that time.
On the other side of the spectrum, if he wasn’t aware of the host(s) it probably wasn’t consecrated. We had another priest who didn’t notice that one of the new servers had placed an ancillary chalice on the altar, on the opposite side from the corporal. When it came time to distribute communion, he saw the chalice, realized he hadn’t had the intention to consecrate it, and simply didn’t use it. He drank it himself later as they were purifying the vessels.
Because Christ acts through the priest (in persona Christi), as long as the priest has the intention, Christ fulfills the action. Because no human, no matter how holy, and no matter how perfectly he may say the prayers, cannot by his merits or powers consecrate the bread and wine into the Body and Blood of Christ. It is entirely the action of Jesus. And he completes with his Grace what is lacking in our nature.
Last point: if the priest has, by action or omission, not consecrated the Body and Blood of Christ at the altar, but the faithful, not aware of this, receive communion in good faith and believe that they are receiving our consecrated Lord, they are receiving the Body and Blood of Christ through the Church. I don’t remember the latin phrase or what the theological concept is called, but if I recall correctly, the latin phrase translates basically to “the Church provides.” Meaning, in the event that the faithful are in a situation where they would be left without the sacraments unknowingly and through no fault of their own, they can be assured that God provides for them through the Church, through whom the priest has his faculties (i.e. directly from the bishop).
Hopefully that covers all the bases.