Hello everybody,
I have this piece of code that is adding drop downs to where is the end of the data. Now, from the first blank data, exactly where the end of data is, I need to continue adding 1000 more drop downs with different set of values.
I have another set of codes below that adds only 1 line and I had to use .Select which I am not happy with.
Is there a way to avoid this .Select and how am I going to loop through and add 1000 more drop downs?
Thanks in advance.
I have this piece of code that is adding drop downs to where is the end of the data. Now, from the first blank data, exactly where the end of data is, I need to continue adding 1000 more drop downs with different set of values.
I have another set of codes below that adds only 1 line and I had to use .Select which I am not happy with.
Is there a way to avoid this .Select and how am I going to loop through and add 1000 more drop downs?
Thanks in advance.
Code:
For i = 2 To LastRow 'loop from Row 2 to Last
With ws.Cells(i, "A").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Selection1,Selection2,Selection3,Selection4"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
If ws.Cells(i, "A").Value = "" Then
ws.Cells(i, "A").Value = "No Selection"
End If
End With
Next i
For i = 2 To LastRow 'loop from Row 2 to Last
With ws.Cells(i, "B").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Selection1,Selection2,Selection3"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
If ws.Cells(i, "B").Value = "" Then
ws.Cells(i, "B").Value = "No Selection"
End If
End With
Next i
Code:
Range("A1").End(xlDown).Offset(1, 0).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Another1, Another2"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
If Selection.Value = "" Then
Selection.Value = "No Selection"
End If
End With
Range("B1").End(xlDown).Offset(1, 0).Select
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="Another3, Another4"
.IgnoreBlank = True
.InCellDropdown = True
.ShowInput = True
.ShowError = True
If Selection.Value = "" Then
Selection.Value = ""
End If
End With