Defining Ranges

When you hide a row or column in Excel, you can still access the values contained in the cells with references in functions and macros. Excel indicates the existence of hidden rows and columns by skipping over the hidden rows and columns with the row and column headings. For example, if you hide columns C and D, you see the column labels for columns A, B, E, F, etc.

You can hide the entire worksheet using either the Columns or Rows properties. Either one of the following produces the same results by hiding either all rows or all columns.

Example:

Columns.Hidden = True Rows.Hidden = True

To unhide rows or columns in a worksheet, you need to set the Hidden property to False. For example, the following code statement unhides all columns in a worksheet.

Example:

Columns.Hidden = False

This statement is useful for ensuring that all cells in a worksheet are visible. If you apply it to a column that is already visible, Excel ignores the statement and the column remains visible. Of course, you can also use the Rows property in the same fashion to unhide any invisible rows.

Example:

Rows.Hidden = False

□ Type For N = StartColumn to EndColumn.

Next.

-■ Excel hides the specified columns.

□ Type For N = StartColumn to EndColumn.

-Q Type Columns(N).Hidden True.

Next.

-■ Excel hides the specified columns.

0 -1

Post a comment