Created
August 8, 2022 20:23
-
-
Save huvanile/706004bd146f97a16fe53fa82d8a283c to your computer and use it in GitHub Desktop.
Example of how to programatically create a long drop-down list in Excel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Macro4() | |
'longVal is collectively more than 255 characters | |
Dim longVal As String: longVal = "Lorem,ipsum,dolor,sit,amet,consectetur,adipiscing,elit.,Fusce,dolor,dui,eleifend,in,blandit,ac,,vulputate,ac,purus.,In,sollicitudin,dolor,at,massa,interdum,vulputate.,Etiam,eu,bibendum,elit.,Lorem,ipsum,dolor,sit,amet,consectetur,adipiscing,elit.,Fusce,dolor,dui,eleifend,in,blandit,ac,vulputate,ac,purus." | |
With ActiveSheet.Range("a1").Validation | |
.Delete | |
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _ | |
xlBetween, Formula1:=longVal | |
.IgnoreBlank = True | |
.InCellDropdown = True | |
.InputTitle = "" | |
.ErrorTitle = "" | |
.InputMessage = "" | |
.ErrorMessage = "" | |
.ShowInput = True | |
.ShowError = True | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment