Count unhidden columns on a spreadsheet

Copper Contributor

I need to count how many unhidden columns there are on a specific excel spreadsheet.  The counter  reflect ALL columns including those that are hidden, which i do not need.

1 Reply

@Carol_Stone I assume you are now using COUNTA for a range of cells that all contain numbers/texts/column headers. Let's say C1:Z1, i.e. 24 columns.

 

You could insert a row (above or below the headers) with a formula using the CELL function. For instance in C3, and copy it across to Z3. This will return the column width for each of the columns. The row may be hidden.

 

=INDEX(CELL("width",C1),1,1)

 

 

Hidden columns have a width of 0 (zero). Then, in the cell where you want to count the number of visible columns enter this:

 

=COUNTIF(C3:Z3,"<>0")

 

 

The only snag with the CELL function is that you need to recalculate the sheet after you have hidden or unhidden a column for the widths to be updated. So, enter something or press F9.

 

Not sure if there is another way. Have never had the need to discover one :)

 

I attached a file with a working example.