How do I change the variant when the variant id is known ? Thank you

How do I change the variant when the variant id is known ? Thank you.