Unless the shot was paced off later, they estimated. I would be interested in knowing about optical range finders and how many were used in the Civil War, but given the ranges, the iron sights they used on artillery and things, I will bet they were not used much as it would take time. I am aware of cannons being "sighted" in Forts and batteries, so it makes sense if they had time they would range finders.
For the fast moving battles where artillery was rushed up, there is no doubt in my mind that experience was the guide.
Same thing for small arms fire. I believe John Huff could have hit Jeb Stuart, using a fence as a rest, with his pistol, at 80 rods (about 400 yards). Given how many years and battles John Huff had fought, and that he was an exceptional marksman, sometime exceptional shots are made.
Given how many battles Jeb Stuart had been in, he had thousands of rounds tossed his way, but given time, one finally connected.