You're trying to begin the loop in a cell and end it in another, which isn't possible because table cells form groups; it's like improperly nesting environments
\begin{A}
\begin{B}
...
\end{A}
\end{B}
which can't work.
Here's a way with etoolbox
(I can't recommend using etextools
that's buggy and unmaintained).
\documentclass{article}
\usepackage{etoolbox}
%Create a table with a specific amount of columns
\newenvironment{vartab}[1]
{\begin{tabular}{ |c@{} *{#1}{r|} } \hline}
{\end{tabular}}
\newcommand{\doentry}[1]{\appto\temp{& #1}}
\newcommand{\entry}[1]{%
\def\temp{}% initialize to empty
\forcsvlist{\doentry}{#1}% add entries
\appto\temp{\\ \hline}% end the row
\temp % deliver contents
}
\begin{document}
\begin{vartab}{3}
& 2 & 3 & 4 \\\hline
\entry{5,6,7}
\end{vartab}
\end{document}
The loop is completely worked out in the first cell, by adding to a temporary command that's expanded at the end.
A different solution uses xparse
and expl3
; note that the dummy first column is not needed any more.
\documentclass{article}
\usepackage{xparse}
%Create a table with a specific amount of columns
\newenvironment{vartab}[1]
{\begin{tabular}{ |*{#1}{r|} } \hline}
{\end{tabular}}
\ExplSyntaxOn
\NewDocumentCommand{\entry}{m}
{
\clist_set:Nn \l_muffel_row_clist { #1 }
\clist_use:Nn \l_muffel_row_clist { & }
\\
\hline
}
\clist_new:N \l_muffel_row_clist % allocate a clist variable
\ExplSyntaxOff
\begin{document}
\begin{vartab}{3}
2 & 3 & 4 \\\hline
\entry{5,6,7}
\end{vartab}
\end{document}

X\begin{vartab}{3}&2&3&4\\\hline\end{vartab}X