* Orbiting the Moon? If so, there have been dozens of spacecraft from various countries that have orbited the Moon, starting with the Soviet Union's Luna 3 in 1959.
* Landing on the Moon? If so, only three countries have successfully landed spacecraft on the Moon:
* United States: With the Apollo missions (1969-1972), 12 astronauts walked on the lunar surface.
* Soviet Union: The Luna program had several robotic landers.
* China: Their Chang'e program has landed multiple robotic probes, including the Yutu rover.
* Impacting the Moon? Many missions, including some designed for flybys, have intentionally crashed on the Moon to gather data or test technology.
Therefore, there is no single answer to your question. It depends on your definition of "visited."
Do you have a specific definition in mind? I can give you a more precise answer if you clarify your question.