Yes, when you rub your eyes, you will get the vertigo easily because of the pressure on the eye nerves. However, you should not rub your eyes often which may let your eyes get the infection through the invisible bacterium. If you feel uncomfortable at the eyes, you could use the eye drops to release the symptom, instead of rubbing the eyes.
Well, it seems that some uncomfortable feelings forced you to rub your eyes. As a matter of fact, this is not a good habit , for this would give rise to some infections or red eyes, as there is plenty of bacteria on our dirty hands. However, there is no relationship between vertigo and rubbing your eyes. Maybe you are quite exhausted recently and you think your vertigo is due to rubbing eyes.
Yes, rubbing your eyes may cause vertigo. Because when you rub your eyes, the eye nerves will get some pressure, at this time, your vision will be affected and you will get the vertigo. You'd better not do this since your hands have a lot of bacterium. You eyes will be in danger of getting infections or red eyes.
I have had this same problem eye rubbing causing vertigo. Later I had high blood pressure and panic attacks and anxiety. The cause for my panic attacks was unknown then later I found that I have some serious infection in blood high ESR and gut bacteria imbalance with parasites. Then I treated the infection then took probiotic supplements and improved my diet.. my anxiety and blood pressure problems are gone now but still I get mild anxiety sometimes. So my advice to you is find out what serious infection you have and treat it.