There's not quite enough information in your post to be sure I know what the problem is. It would be helpful to know what VarList is, and what the result of the <<Get Selected() message is. However, I suspect that VarList is a list of columns, liket this:
dt=open("$SAMPLE_DATA\Big Class.jmp");
varname={:age, :sex};
If so, then you need to put use Eval() around varname in the Summarize() function, like this:
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );
varname = {:age, :sex};
//varName = VarList <<Get selected();
numCols = N Items( varName );
n = N Row( dt );
If(
numCols == 0,
//do one thing
,
numCols > 0,
Summarize( dt, cat = by( Eval( varname ) ), c = count );
//do other things
);
-Jeff