equation for extrusion thickness

I want to make some shelves that change dimensions as I change width and depth of the alcove they fit in, I have managed to get that to work by adding values for w and d but cannot work out how to get the extrusion thickness linked to an equation as opposed to inputting it every time.

Also could you please look at the attached files and suggest any improvements?

thanls in advance, Derek.

SolidworksAssemblies