(実際のニーズにそれを調整するためのコメントを参照してください):
Sub Main()
With Worksheets("sheetWithDropDownName").Range("A1").Validation '<--| change "sheetWithDropDownName" and "A1" to your actual "dropdown" worksheet and cell references
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:=Join(GetTitles(), ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
Function GetTitles() As Variant
Dim cell As Range, rng As Range
With Worksheets("sheetWithDataName") '<--| change "sheetWithDataName" to your actual sheet with data name
Set rng = .Range("A1", .cells(.Rows.Count, "E").End(xlUp)) '<--| set a range as its columns A:E range from row 1 down to last column E not empty row
End With
With CreateObject("Scripting.Dictionary")
For Each cell In rng.Columns(5).cells
If cell.Value = "index" Then .Item(cell.Offset(, -4).Value) = cell.Offset(, -4).Value
Next cell
GetTitles = .keys
End With
End Function
あなたが書いている_ "ベースあなたの疑似コードは実際に_Cell D_をいくつか使用しますが、リンクされた画像が列 "E"に表示する '' index''と比較します。 – user3598756
ごめんなさい、私は列Eを意味しました – Jeremie
それに応じて質問を編集してください – user3598756