There's no counter that keeps track of the number of columns in a tabular. There's also a complication due to the fact that \cmidrule looks forward to see whether another \cmidrule command follows and the literal token must be found.
If you are happy with a command \cmidrules that has an argument specifying the number of columns, then this can be done in a sneaky way, by preparing a token list inside a \noalign and delivering it at once after closing this \noalign:
\documentclass{article}
\usepackage{booktabs}
\usepackage{expl3}
\ExplSyntaxOn
\tl_new:N \g_michael_cmidrules_tl
\cs_new:Npn \cmidrules #1
{
\noalign
{
\tl_gclear:N \g_michael_cmidrules_tl
\int_step_inline:nnnn { 1 } { 1 } { #1 }
{
\tl_gput_right:Nn \g_michael_cmidrules_tl
{
\cmidrule(l{\tabcolsep}r{\tabcolsep}){##1-##1}
}
}
}
\tl_use:N \g_michael_cmidrules_tl
}
\ExplSyntaxOff
\begin{document}
\begin{tabular}{c c c c c}
Col1 & Col2 & Col3 & Col4 & Col5\\
\cmidrules{5}
data1 & data2 & data3 & data4 & data5\\
\end{tabular}
\end{document}

I used expl3 just for the convenience of using \int_step_inline:nnnn, but a “classical” version can be defined:
\makeatletter
\newtoks\MD@cmidrules
\newcommand{\cmidrules}[1]{%
\noalign{%
\global\MD@cmidrules={}%
\toks@={\cmidrule(l{\tabcolsep}r{\tabcolsep})}%
\count@=\z@
\loop\ifnum\count@<#1\relax
\advance\count@\@ne
\edef\MD@temp{\the\toks@{\the\count@-\the\count@}}%
\global\MD@cmidrules\expandafter{\the\expandafter\MD@cmidrules\MD@temp}%
\repeat
}%
\the\MD@cmidrules
}
\makeatother
array/tabularcells – Werner Mar 15 '16 at 00:21