Maybe we need to step back to some very basic concepts.
A Prime lens is a fixed focal length lens and is optimized for sharp focus, corona aberration, and other lens properties.
A Zoom lens tries to cover a number of various focal lengths and has a sweet focal length for which the majority of lens properties are optimized and only acceptable at other focal lengths.
If you want to shoot Macro, it is best to use a prime lens designed for macro work. If you must use a zoom lens, then find the best focal length for that lens and use that length. So setting the focal length to the largest or smallest value may put your lens at the end of the reasonable results.
Focusing in a Macro mode is different than in the macro mode. In the Macro mode the lens focal length determines the magnification and the camera to object adjust the focus. That is why there are focus rails for serious macro shooters. You might want to switch to manual focus.
Another point to consider is that Macro images are magnified from the Macro image and camera shake, mirror slap, or any camera movement is magnified. So you either need a very good tripod and remove all sources of movement or have a very good VR lens and very good hand holding technique along with breath control.
If you look at the meta data for images shot with a prime lens you will see a tag for the "Effective focal length" as well as the "focal length". If you put a 50nn focal length lens on a D4 the values for these tags will be the same. If you put that same 50mm lens on your D5100, the focal length will be 50mm but the effective focal length will be 75mm. If you were to look through the viewfinder, you would see that the D5100 showed less of the scene than the D4 would show. And the amount less would be more than the 5% difference in the viewfinder. See "Field of View Values for Common Focal Lengths" And if you printed the captured images you would see that the D5100 only captured the 50% center section of the D4 image. The effective focal length is a means of comparing a 35mm size sensor to a different sized sensor for the users of 35mm film cameras. And since the original digital cameras had a sensor smaller than the 35mm cameras, it was referred to as the "crop factior".