Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the code below for doing this now, as part of a function. It needs to
take into account that: - the array may not be dimensioned yet - the array may be dimensioned, but Item(0) is 'empty" - the array may be added to (this function may be called multiple times and add to the array on each call) It works and all, but looks so...inelegant. Anyone see anything I'm doing wrong here? I'm wondering if I could encapsulate this generically somehow. It seems the only tricky part in doing that would be the test for Item(0) being empty, which seems like it needs to be a logical test unique to the items you are storing. Any ideas? Worth it? Thanks, Eric --------------------------- Dim restoreIndex As Integer On Error Resume Next ' in case the array is not dimensioned yet Dim bFirstAdd As Boolean ' true if the array is either not dimension or dimensioned but empty ' tests for emptiness, and will generate error 9 if not dimensioned bFirstAdd = IsNothing(m_filterRestore(0).m_wksName) If Err.Number = 9 Then ' not dimensioned yet. so let's do it ReDim m_filterRestore(0) bFirstAdd = True On Error GoTo 0 End If restoreIndex = IIf(bFirstAdd, 0, UBound(m_filterRestore) + 1) ReDim Preserve m_filterRestore(restoreIndex + (fltrs.Count)) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dynamic Arrays | Excel Discussion (Misc queries) | |||
Dynamic arrays | New Users to Excel | |||
Dynamic Arrays | Excel Worksheet Functions | |||
Dynamic Arrays as arguments | Excel Programming | |||
Dynamic Arrays | Excel Programming |