A viscoelastic agent for ophthalmic surgery is prepared by dissolving sodium hyaluronate and hydroxypropyl methylcellulose in a phosphate buffer respectively, mixing, performing filtration, sterilization, separate packaging, sampling inspection and processing. The mass content of hyaluronic acid in the viscoelastic agent is 1%-1.8%, and the mass content of hydroxypropyl methylcellulose in the viscoelastic agent is 0.2-1.0%. The medical sodium hyaluronate gel and ophthalmic hydroxypropyl methylcellulose used in the invention are two most commonly used viscoelastic agents in ophthalmic surgery of cataract extraction, intraocular lens implantation, and the like, and have been used clinically for years, and the safety and effectiveness have been validated clinically. The medical sodium hyaluronate gel has good cohesion, can support the anterior chamber of the eye well; the ophthalmic hydroxypropyl methylcellulose has good viscosity and strong adhesion, can protect ocular tissues such as cornea well; and the combination of the two can enlarge the application scope of the viscoelastic agent, and can be used in ophthalmic surgery.