Is there an injective operator with a dense nonclosed one-codimensional range?

There is no such an operator. More generally, a continuous operator on a Banach space with finite dimensional kernel and cokernel must have a closed image (such operators are called Fredholm). Let me prove this for your specific case. Let $A \colon H \rightarrow H$ be continuous, injective and $\dim H/\operatorname{Im}(A) = 1$. Choose $v \notin \operatorname{Im}(A)$ and note that $\operatorname{Im}(A) + \operatorname{span} \{ v \} = H$. Consider the map $\tilde{A} \colon H \oplus \mathbb{C} \rightarrow H$ given by $\tilde{A}(h,z) = Ah + zv.$ This map is one-to-one, onto and continuous so by the open mapping theorem, it has a continuous inverse $\tilde{A}^{-1} \colon H \rightarrow H \oplus \mathbb{C}$. By the definition of the external direct sum, $H$ is a closed subspace of $H \oplus \mathbb{C}$ and then $\tilde{A}(H) = \operatorname{Im}(A)$ is closed. This proof works verbatim if you consider more generally an injective continuous linear map $A \colon B_1 \rightarrow B_2$ between Banach spaces with codimension one cokernel.


Take $V$ to be a non-closed subspace of $H$ with codimension $1$. Because of the codimension, we know that there exists a basis (an infinite, Hamel basis) for $V$ which can be extended into a basis for $H$ by adding a single vector. These bases for $V$ and $H$ have the same cardinality. So, there must exist a bijective linear map from $H$ to $V$.


If you mean $\operatorname{codim}(\overline{\operatorname{Im}(A)}) = 1$, there is indeed such an operator. Take $H = \ell^2$ and $$ A[(x_n)] = \left(0,\frac {x_1}1,\frac{x_2}2,\frac{x_3}3,\dots\right) $$ The image of $A$ is non-closed, but its closure is $\{(x_n): x_1 = 0\}$.