I'm currently having a problem where an auto-filtered range is only placed inside an array on the first loop but subsequent attempts to do the same despite the range filtering correctly don't work.
Code:
Set OpenWBS = Workbooks(Workbooks.Count).Worksheets(1).UsedRange
strData = OpenWBS.Columns(T).Value2 'contract codes column has been added to array[T is a number]
strData = No_Repeats(strData, strData(1, 1), UBound(strData, 1)) 'remove duplicates
For Each element In strData
Select Case element
Case strData(LBound(strData)) 'skip over headers
Case Else
OpenWBS.AutoFilter Field:=T, Criteria1:=element, Operator:=xlFilterValues, VisibleDropDown:=false
'filtering worksheet for rows with the specified contract code
[COLOR=#ff0000]Temp_Array = OpenWBS.SpecialCells(xlCellTypeVisible).Value2[/COLOR]
Contract_ID = element
If Not ThisWorkbook.All_Contracts.Exists(Contract_ID) Then
'if the Contract_ID Key does not exist then create a new dictionary
Set C_Dict = New Scripting.Dictionary 'create a new dictionary with the Contract_ID as a key
ThisWorkbook.All_Contracts.Add Contract_ID, C_Dict
'add the new dictionary to the orginal
End If
Set C_Dict = ThisWorkbook.All_Contracts.Item(Contract_ID) 'dictionary within a dictionary
For X = LBound(Temp_Array, 1) + 1 To UBound(Temp_Array, 1) 'offset by 1 to skip headers in visible range
D = Convert_Date(Temp_Array(X, 2)) 'the 2nd element corresponds with a date string--> convert to serial date
C_Dict.Add D & "-" & Temp_Array(X, 1), WorksheetFunction.Index(Temp_Array, X, 0)
'key is SerialDate-Name
Next X
OpenWBS.AutoFilter Field:=T 'clear the autofilter from the contract column
'Erase Temp_Array
End Select
Next element
Last edited: