В моей базе данных есть 100 столбцов, причем столбец A представляет собой уникальный список идентификатора сотрудника, а столбец K - статус оплаты каждого сотрудника (освобожден, почасовой, не освобожден и т. Д.). Как извлечь список идентификатора сотрудника (из столбца A), который имеет статус «освобожден» (из столбца K) - используйте словарь, пожалуйста! Другими словами, как перейти к шагу 2 в моем коде ниже?
Public Sub ExtractEmployeePayStatus()
Dim i As Integer
Dim p As Integer
Dim cell As Range
Dim rangeData1 As Range
Dim rangeData2 As Range
Dim rangePerform1 As Range
Dim rangePerform2 As Range
Dim dictionaryData1 As Scripting.Dictionary
Dim dictionaryData2 As Scripting.Dictionary
Dim strValue1 As String
Dim strValue2 As String
Dim w As Variant
Dim v As Variant
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Step 1 = Load employee numbers (unique list in column A)
Set rangeData1 = Sheets("Database").Range("A9:A2008")
Set dictionaryData1 = New Scripting.Dictionary
dictionaryData1.CompareMode = TextCompare
With rangeData1
For Each cell In rangeData1.Columns(1).Cells
i = i + 1
strValue1 = cell.Text
If Not dictionaryData1.Exists(strValue1) Then
dictionaryData1.Add strValue1, .Rows(i)
Else
Set rangePerform1 = Union(.Rows(i), dictionaryData1(strValue1))
dictionaryData1.Remove strValue1
dictionaryData1.Add strValue1, rangePerform1
End If
Next cell
End With
p = -1
For Each w In dictionaryData1.Keys
p = p + 1
Debug.Print dictionaryData1.Keys(p) '<<<<Possible to print related column K values???
Next w
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Step 2 = Load employment status (not unique list in column K)
'''''How to load this???? How to do Step 2???
'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Step 3 = Compare Step 1 result vs Step 2 result
''''' I want to use dictionary per above to extract employee IDs (from column A) whose status is "Exempt" (from column K).
''''' I want to use dictionary because I have 10,000 employee IDs. Dictionary will go faster.
End Sub