If you want to use his, then you can modify your code as shown:
Sub AppleDepartmentCode()
Dim Target As Range
Dim sContent
Dim c As Range
Dim PctDone As Double
Dim CellCount As Long
Set Target = Selection.SpecialCells(xlCellTypeVisible)
Application.EnableEvents = False
CellCount = 0
For Each c In Target 'for every cell in the selection
CellCount = CellCount + 1
If Not (c = "") Then 'if the cell in the selection is empty then move onto the next cell
sContent = c.Value ' store the current contents of the cell
With c
' put array formula in cell using the stored cell's contents
On Error Resume Next ' trap any error
.FormulaArray = _
"=INDEX([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$2:$K$2,SMALL(IF([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40=""" & sContent & """,COLUMN([PERSONAL.xlsb]ZZZZZZZAppleDepartmentNAME!$A$1:$K$40)),1))"
On Error GoTo 0
' convert the formula to a value
.Value = .Value
' if the value is an error type, restore the original contents
If Left(CStr(.Value), 5) = "Error" Then .Value = sContent
End With
End If
PctDone = CellCount / Target.Count
With UserForm1
.FrameProgress.Caption = Format(PctDone, "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
End With
DoEvents
Next c
Application.EnableEvents = True
End Sub
Bookmarks