Some level of good news to you.
You can do it with formulas, without VBA, but everytime you hide or unhide column you need to recalculate your formula by pressing Ctr+F9 keys.
I have used one row to check the width of column. if it is more than 0 that means not hidden, it will count that column. And if width is 0, that means hidden, it will skip to count it.
check the attached file table 2.
Regards,
Prasad DN