You want a linear transformation $f:V\to W$ with given kernel $X$. You can find a basis for $X$, extend it to a basis for $V$, take the basis for $X$ to zero, and take the other basis vectors of $V$ to linearly independent elements of $W$ (by first finding a basis for $W$). I'm assuming here that all your spaces are finite-dimensional, and that the dimensions are such that this kind of kernel is possible.
For a given range $Y$, you can do something similar. Find a basis for $Y$, take basis vectors of $V$ to these basis vectors of $Y$, making sure that each basis vector of $Y$ is the image of at least one of the basis vectors of $V$.
In both cases, once you've worked out where the basis vectors go, extend the map to all of $V$ by linearity.