You may try something like this to make it more robust.
Right click on Tracker Sheet Tab --> View Code --> Place the following two codes into the opened code window.
The selection change event code will insert a drop down list of Case Numbers dynamically when you select the cell C2.
The change event code will trigger a macro that will fetch the relevant data from the DumpSheet as per the case number selected in C2.
Codes on Tracker Sheet Module:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
Dim lr As Long
If Target.Address(0, 0) = "C2" Then
If Target <> "" Then
Application.EnableEvents = False
Call GetRelevantData
Application.EnableEvents = True
Else
Application.EnableEvents = False
lr = Cells(Rows.Count, 2).End(xlUp).Row
If lr > 5 Then Range("B6:F" & lr).Clear
Application.EnableEvents = True
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
Dim sws As Worksheet
Dim x, dict
Dim lr As Long, i As Long
If Target.Address(0, 0) = "C2" Then
Set sws = Sheets("DumpSheet")
lr = sws.Cells(Rows.Count, 6).End(xlUp).Row
x = sws.Range("F2:F" & lr).Value
Set dict = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(x, 1)
dict.Item(x(i, 1)) = ""
Next i
With Target.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(dict.keys, ",")
End With
End If
End Sub
Code on Standard Module:
Now insert a New Module and place the following code into the new code window.
Sub GetRelevantData()
Dim dws As Worksheet, sws As Worksheet
Dim lr As Long
Application.ScreenUpdating = False
Set dws = Sheets("Tracker")
Set sws = Sheets("DumpSheet")
lr = dws.UsedRange.Rows.Count
If lr > 5 Then dws.Range("B6:F" & lr).Clear
sws.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=dws.Range("C1:C2"), _
CopyToRange:=dws.Range("B5:F5"), _
Unique:=False
lr = dws.Cells(Rows.Count, 2).End(xlUp).Row
If lr > 5 Then
dws.Range("B5").CurrentRegion.Borders.Color = vbBlack
End If
Application.ScreenUpdating = True
End Sub
For details, refer to the attached. To test the code, select a case number in C2 on tracker sheet.
Bookmarks