Yes it will work. But let's consider performance and readability.
Performance
You are invoking countModules
3 times for the "col2" case, once for the "col3" case assuming you are starting with "col1" it will be 4 invocations,each with multiple "positions" to check for.
Now the countModules()
code is pretty optimized, falling back to a single static class that will not query the db at every iteration; but you're still making your program 10 times slower than it should be even in a small site with few modules.
Readability & code quality
You might have read that code should not look like it's copied and pasted. That makes sense at least because it's easier to read code that avoids duplication, additionally it will be less prone to typos.
In the spirit of condensing multiple statements, instead of joining lines, why not consider:
$colCount = 0;
foreach(array('Top1A','Top1B','Top1C') as $position) {
if ($this->countModules($position)) {
$colCount += 1;
}
}
$modCellRow1 = "col" . $colCount;
This will return "col0"
if no modules are in any of the positions, "col1"
if modules are present only in one and so on.
I wrote it so it's easiest to read,