XLA routines: EE_RangeTrim
Use EE_RangeTrim to trim a range that is passed to date functions to make the calc quicker
Function EE_RangeTrim(rng As range) As range 'Returns a new range containing only the populated cells '- use RangeTrim for all the date functions to prevent looping through the whole range. Dim rngC As range 'http://excelexperts.com/xla-routines-eeRangeTrim for updates on this function If rng.Cells.Count = 1 Then If rng.value <> vbNullString Then Set EE_RangeTrim = rng Exit Function End If End If On Error Resume Next Set rngC = rng.SpecialCells(xlCellTypeFormulas) If Not rngC Is Nothing Then Set rngC = Union(rngC, rng.SpecialCells(xlCellTypeConstants)) Else Set rngC = rng.SpecialCells(xlCellTypeConstants) End If Err.Clear: On Error GoTo 0: On Error GoTo -1 Set EE_RangeTrim = rngC End Function
»
- Nick's blog
- Login or register to post comments
- 2813 reads
Recent comments
5 years 42 weeks ago
6 years 28 weeks ago
6 years 40 weeks ago
6 years 42 weeks ago
6 years 43 weeks ago
6 years 49 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago
7 years 5 weeks ago