More on TrimRange and the Drop Function

A comment on my previous post links to a helpful YouTube video on using TrimRange and the Dot operator:

It also looks at using the Drop Function to exclude a specified number of rows and/or columns from the top or left of the selected range.

I have added the Drop Function to some examples from the previous post, also adding some text in one cell above the data range:

In Column G Drop has been used in conjunction with the Dot operator excluding empty rows from both the top and bottom of a single column (B.:.B). This removes the first two rows of data, which is not what we want. If the Dot operator is used to exclude only the empty rows at the end (B:.B), Drop then removes Rows 1 and 2, and returns all the data from Row 3 to 15. In Column K the number of rows to be excluded has used the Row function, so that if the data is moved, or if rows are inserted above the data, the formula will still return the data from the top of the table, excluding all new rows above.

The Drop function can also be used to remove columns, and/or rows, in conjunction with the TrimRange function:

In column U the Dot operator is used to return Columns A to E, with empty rows excluded. The Drop function then removes the top 2 rows, and 1 column from the left (Column A), leaving only rows with at least one column containing data.

In Column Z the same result has been achieved using the TrimRange function, rather than the Dot operator, again removing 2 rows and 1 column with the Drop function.

This entry was posted in Arrays, Excel and tagged , , , , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.