Take your last result and simplify it a little bit:
Now plug in this term for d into the equation of the volume. You'll get the equation of a function calculating the volume with respect to w:
Now calculate the domain of the function, then the first derivative of V, solve for w the equation
I'll asumme that you can handle this procedure.