I think TRIMRANGE will be useful, but I'd like to propose an alternative, (or additional) function that might be called EXPANDRANGE. The idea would be to expand a range until it is surrounded by blank cells (or the edge of the worksheet), much like the .CurrentRegion property in VBA or the # annotation for cells containing a dynamic array.
Here's draft documentation:
EXPANDRANGE(input_range, [go_down], [go_right], [go_up], [go_left])
Returns a reference to a range which is the input_range extended in each of the requested directions until cells bordering the returned range are empty.
Arguments:
input_range:
A range of cells.
go_down:
True if the range is to be expanded downwards. If TRUE (the default), all cells one below the returned range will be empty, or the returned range will extend to the last row of the worksheet.
go_right:
True if the range is to be expanded rightwards. If TRUE (the default), all cells one to the right of the returned range will be empty, or the returned range will extend to the last column of the worksheet.
go_up:
True if the range is to be expanded upwards. If TRUE (the default), all cells one above the returned range will be empty, or the returned range will extend to row 1.
go_left:
True if the range is to be expanded leftwards. If TRUE (the default), all cells one to the left of the returned range will be empty, or the returned range will extend to column A.