I'm trying to create a Drop Down list in Excel with the help of an Array. Unfortunately, I have some problems with my code (I won't show all my code I'm afraid it is too long).
Here is the part of the code for adding what I want in the Array :
Dim Range_Protection As Range
Dim Row_Range As Range
Dim Tableau As Range
Dim Protection_First_Value As String
Dim Protection_Last_Value As String
Dim Array_List() As String
Dim Taille_Array As Integer
If Not Range_Protection Is Nothing Then
'The value I want to get are String, don't know if I should use "Cells.Text" instead
Protection_First_Value = Tableau.Cells(1, 1).Value
For Each Row_Range In Range_Protection.Rows
Protection_Last_Value = Row_Range.Cells(1, 1).Value
'I'm checking the value of each rows
'Everytime there is a new value, I add it to the Array
If Protection_First_Value <> Protection_Last_Value Then
Protection_First_Value = Protection_Last_Value
'Taille_Array is already determined earlier in the code
For Count = 0 To Taille_Array
Array_List(Taille_Array) = Protection_Last_Value
Next Count
Else
End If
Next Row_Range
End If
And the code for creating the Drop Down list :
With Range("ListeD_Protection").Validation
.Add Type:=xlValidateList, Formula1:=Join(Array_List, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
I always have the same error, no matter what I try to do at the same line :
.Add Type:=xlValidateList, Formula1:=Join(Array_List, ",")
Here is the message :
'1004': Application-defined or object-defined error
I did some researches on the internet but could find nothing about a problem similar as mine. After hours of thinking, I'm stuck and can't see what's wrong even though it's certainly just a small error somewhere in my code.
Can someone tell me if you can understand what is the problem, I would be really thankful.
