L
L. Howard
I found this code that makes a DV drop down.
The example to populate the array was like this, which produced a DV with selections of 1, 2, 3, 4, 5.
Dim ValidationList(5) As Variant
Using the example from a Chip P's site (commented out in the code) I want the list in column F to be the DV source list.
The only difference I see is the array name and the range to read into it. But it throws a subscript out of range error.
Thanks,
Howard
Sub DV_Test()
Dim ValidationList() As Variant, i As Integer
ValidationList = Range("F1:F10")
' Dim Arr() As Variant
' Arr = Range("A1:A10")
For i = 0 To UBound(ValidationList)
ValidationList(i) = i + 1
Next
With Range("A1").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:=Join(ValidationList, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
The example to populate the array was like this, which produced a DV with selections of 1, 2, 3, 4, 5.
Dim ValidationList(5) As Variant
Using the example from a Chip P's site (commented out in the code) I want the list in column F to be the DV source list.
The only difference I see is the array name and the range to read into it. But it throws a subscript out of range error.
Thanks,
Howard
Sub DV_Test()
Dim ValidationList() As Variant, i As Integer
ValidationList = Range("F1:F10")
' Dim Arr() As Variant
' Arr = Range("A1:A10")
For i = 0 To UBound(ValidationList)
ValidationList(i) = i + 1
Next
With Range("A1").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlEqual, Formula1:=Join(ValidationList, ",")
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub