And how many planes did it actually shoot down?
The Bofors 40mm, together with the Oerlikon 20mm, were the principle automatic AAA defense weapons of the US Navy during the war (though many other nations used the types, especially the British). When talking about AAA defenses, you need to consider 1) the qualities of the gun itself (ballistics, reliability, jamming, etc), 2) the type of ammunition, and 3) the method of aiming.
To add to what the other user posted, you can read more about the American VT proximity rounds here.
As for the aiming, this varied with the type of ship the gun was installed in. In a small vessel, or an isolated battery on a larger ship, the gun might well be fired under local control, with the gunner seated behind a sight and moving the weapon manually and guessing how much to lead the target. Larger vessels often had a fire control system, wherby one or more 40mm weapons would be "slaved" to the more advanced optics of some sort of solution-computing predictor in the fire control station. After the war, radar-guidance replaced these optical predictors, making the weapons even more accurate; derivatives of the Bofors 40mm are still in service today with these advanced fire control radars, and pose a high threat to any aircraft within it's engagement zone.
However, a weapon is only as good as it can be aimed, and aircraft were winning the arms race between planes and air defenses during WW2. Compare this image with this one. The first one is a German Bayern-class battleship from the First World War. Note the clean deck, and how little tertiary armament is visible. The second one is of two American Iowa-class battleships from the end of the Second World War. The only thing that could be done to defend ships from aerial attack, short of using fighters to take down aircraft that were attacking the ships, was to cram them with as many AAA weapons as possible to ensure a hit. If a ship was under attack by enemy aircraft, AAA was the last resort, not a primary defense. The primary defense were fighter aircraft sent out to intercept attackers before they came within sight of the ships.
At War With the Wind, by David Sears, is a good book about the US Navy's fight against Kamikaze attacks, and is a good source to get a handle on AAA defenses, how they worked, and their limitations.
Piggyback Question: What happened to the rounds/shrapnel of the rounds that were sent up, but did not hit planes? Was there a constant terrible rain of rounds upon the homeland are the rounds completed their arc?
Here is a report produced by the US Navy shortly after the war that summarizes the effectiveness of its various AA guns. Since these are wartime reported kills the numbers may be inflated, but it should be a decent guide, especially with regards to percentages per gun and rounds required per kill.
In brief, the Bofors 40mm shot down 742.5 planes, or 33% of the total AA victories, and required an average of 1713 rounds per kill.
This source:
http://www.history.navy.mil/library/online/antiaircraft_action_summary_wwii.htm
Estimates that 200 enemy planes were shot down by US merchant ships in WWII and that enemy planes sunk or damaged 124 US merchant ships.
I remember reading somewhere that it was considered that defensive AA fire from merchant ships improved ship survivability, as it deterred the attacking planes from pressing home a more accurate attack. Unfortunately, I cannot find the source.
The same source credits the 40mm gun as the most effective AA armament in the US battle fleet. It credits the 40mm with 742 enemy aircraft kills vs. 617 for 20mm guns, 346 for 5"VT rounds, 342 for 5"Com rounds, 87 for 3" rounds, 65 for .50 cal, and 48 for other ammo.
The source claims that 7,600-7,800 enemy aircraft came within AA range of US ships. Of these, 2,773 (note: includes 2,256 "assessed kills" plus an estimate of damaged planes which did not successfully return to base) were shot down by AA, and another 314 were lost through crashes (suicide crashes) on US ships (the explanation for why planes lost to suicide crashes are counted as fewer than ships damaged by suicide crashes is that the source claims 314 suicide plane hits on ships with the rest being damaging misses (presumably some counted as shot down by AA)).
The source reckons that 114 US ships were sunk by enemy aircraft in WWII, and 435 damaged (425 of the 549 US ships sunk or damaged were warships, 124 were merchant ships) (143 of the total sunk and damaged by bombs, 51 by torpedoes, 352 by suicide attacks, 3 by strafing).
The source further estimates that of the 7,600 enemy planes coming into AA range of US ships, 715 actually made a sinking or damaging hit on a US ship (sometimes several planes hitting the same ship).
How accurate these estimates are is unknown.
If they are roughly accurate, the 40mm Bofors was a pretty effective AA defense. The total number of AA kills by the Bofors in WWII would need to include kills by Bofors deployed by forces other than the US navy and Merchant Marine, but I have been unable to find any sources for those.
I'm not really a historian, just a fanatic.
The guns were pretty useful but only in big numbers. It would take thousands of rounds to take down a plane or bomber. It wasn't necessarily the gun that did the killing but the ammunition. I believe about a year into the second world war, the allies created radio frequency rounds which would explode when they detected a nearby airplane. These rounds were much more effective than the earlier flak guns that had to be set to explode at a certain altitude.
The aa guns at the time we're very useful but are nothing compared to today's anti aircraft weapons.