Here I will list code for some useful VBA functions that deal with an Excel range. I think the function descriptions are self-explanatory.

### Determine Last Row in a Range

Function GetLastRow(rng As Range) GetLastRow = rng.Rows.Count + rng.Row - 1 End Function

### Return an Array of Row Numbers from a Range

Function RowsFromRange(rng As Range) Dim c As Range Dim i As Integer Dim arr() As Integer ReDim arr(rng.Rows.Count - 1) For Each c In rng.Rows arr(i) = c.Row i = i + 1 Next RowsFromRange = arr End Function

## No comments:

## Post a Comment