Is there any way to replace an object?
As usual there is may ways to achieve this. One approach would be to use the Link Object Data function, which basically allows you to swap out the Mesh Data (i.e. what you have in Edit Mode) with a selected mesh. The shortcut is Ctrl + L. See it in action here:



Whichever method you choose, you might get issues in regards to scale. If your cubes have different scale values in the Transform Panel, the spheres will have those different scales as well. If you had applied the scale before, all final spheres will be equally sized.

Even more important is the scale of the sphere. If that is not applied, but the cubes are, the resulting spheres will have a different size than the 'original'. The reason for both behaviors is this: The final representation of an object is a combination of Object and Object Data. The object holds the location, rotation and scale values. The data holds the mesh vertex coordinates, face info, etc. But the mesh data stores this info always as if the scale was 1. The output for the user is however displayed as the combination of both at all times. So before the sphere gets displayed on the screen, Blender applies the transformation matrix onto each vertex, and shows you the final result.

Final note: With this method, all objects will share the same mesh data. If you manipulate one, all of them will update when you exit Edit Mode.