(from quora)
First, how many stars are in the universe? The various space telescopes and investigations of the past century have been narrowing in on that number, but it is still not entirely known. For a back-of-the-envelope calculation, we can use an estimate of 10^12 galaxies, each of which has 10^12 stars. I added a link below to an European Space Agency article that puts the total number of stars between 10^22 and 10^24.
Now for sand.
Arid regions cover over 20% of the Earth's land masses. With 70% of the Earth covered in water, that means 20% of the remaining 30% (or 6% of the Earth) can be approximated as "sandy." Now it is true that some arid regions are not sandy (e.g. bedrock-dominated desert lands like those found in central Utah and other areas of the Colorado Plateau), but likewise some sandy regions are not arid (e.g. beaches). Let's assume that for this order of magnitude calculation, those differences balance out to about equal.
So 6% of the Earth is covered in sand. What does that mean? Well the radius of the Earth is 6,378 km, and with a quick 4/3*pi*r^2 we get that the surface area of the Earth is 1.7 x 10^8 km^2. 6% of this is then about 10^7 km^2. Say the average depth of active, non-lithified sand in these regions is 1 m. Now we have 10^4 km^3 of sand total.
So how many grains are in 10^4 km^3 of sand?
That depends on many things, but the easiest one to consider is the size of your sand grains. If we assume the world is full of only medium sand (i.e. 250-500 micron diameter grains), and we assume that they are all nicely packed spheres, then we can estimate how many sand grains are in one cubic kilometer of sand.
In general, sand does not pack quite so nicely, and not all grains are the same size, but let's roll with it and see what we get. Remember this is an order of magnitude calculation.
Let's call all our grains 250 microns (1/4 mm). So in a cube of space, 1 km long on each side, we could fit 4 million grains of sand in each dimension. Thus in the box there are 4 million cubed or roughly 10^20 grains of medium sand per cubic kilometer of sandy space. Recall that we have 10^4 km^3 of sand and we have 10^24 grains of sand on Earth.
Cool!
So depending on what parameters you pick, I would say that there are about as many grains of sand on Earth as there are stars in the universe.