In your setup, you are trying to capture the Position vectors (via
Store Named Attribute) in the Instance domain, but at that step there aren't any instances created yet so the capture fails. Simply switch to the Point domain and the information will be captured correctly:
However, even now that we're managing to bring that information into our shader, there's one big problem: to the best of my knowledge, those values are written on the very geometry the Geometry Nodes modifier is manipulating—they don't magically become available to any and all objects. When you ask a shader to use values captured by a GN modifier, shader tries to read those values from the geometry it is currently assigned to. We captured two Position vectors on our points, but those points aren't in the Cylinder's mesh, they're in the two Grids we instanced in the GN object, so the shader fails to find anything to read (see the bottom of the post for a visual demonstration).
This insight makes it obvious as to how we can affect the colors of the Cylinder with our GN setup: we need to bring the Cylinder into our GN tree so its geometry becomes available to capture values on:
GN SETUP. We sample the position vectors from the points, but capture them as attributes on the Cylinder's geometry. I also took the liberty of swapping out the two Grids with the two Toruses available in the file.
Now to use that captured information in the shader. Simply comparing the two vectors (or rather their separated Z components) to each other like in your setup doesn't yield the desired result, because what we wanna compare them to is the shader's coordinate system itself. We get that from the Position socket of the
Geometry node. If the Position—Z of the geometry the shader is assigned to is lesser than the captured Bottom value OR greater than the captured Top value, use the Green shader, otherwise use the Pink:
SHADER SETUP. The OR logic gate node is from this answer
BONUS: Here's a demonstration of the shader failing to read values captured by the GN setup if it's not assigned to the same object. Below, you can see the Cylinder as re-created in the GN setup on the left, and on the right the original Cylinder with no GN setup, both using the same shader. The one with the GN modifier can correctly compare the captured position with its own coordinates, but the one on the right cannot read those values which means it gets a blanket value of $0$, so everything greater than $0$ gets colored green, and everything smaller gets colored pink: