1 Attachment(s)
Creating dynamic List on Workbook Startup
Good morning everyone,
I'm trying to create a dynamic list once Workbook is open. Can you guys help me what is wrong with my code?
Code:
Private Sub Workbook_Open(ByVal Target As Range)
Dim d As Object, i&, arr '
Set d = CreateObject("scripting.dictionary")
arr = Worksheets("Temp").Range("_Nompipesize")
Worksheets("Calc").Range("E2").Value = ""
With d
For i = 1 To UBound(arr)
If Not .Exists(arr(i, 1)) Then d(arr(i, 1)) = ""
Next i
End With
If d.Count > 0 Then
With Worksheets("Calc").Range("E2")
.Validation.Delete
.Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(d.Keys, ",")
.Value = d.Keys
End With
End If
End Sub
Attachment 26411