I am trying to insert dropdowns in sheet1 based on data in sheet2.
This works part of the code works:
Sheets("Sheet1").Activate
However,this part of the code doesnt and it is exactly the same except for the column selection: I keep getting the Application defined or object defined error
I checked and i realized this could be because the column A is populated with hyperlinks. Could this be a reason? If yes, any workaround? i dont need the url in the dropdown,just the text that i used to display the hyperlink.
This works part of the code works:
Sheets("Sheet1").Activate
VBA Code:
Range("B7").Select
x = Sheets("Sheet2").Range("D500").End(xlUp).Row
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=DROPDOWNS!$D$2:$D$" & x
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
However,this part of the code doesnt and it is exactly the same except for the column selection: I keep getting the Application defined or object defined error
VBA Code:
Range("B20").Select
x = Sheets("Sheet2").Range("A500").End(xlUp).Row
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=Sheet2!$A$2:$A$" & x
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
I checked and i realized this could be because the column A is populated with hyperlinks. Could this be a reason? If yes, any workaround? i dont need the url in the dropdown,just the text that i used to display the hyperlink.