Hi all.
What I need –
A blank option in a data validation dropdown (VBA)
The problem –
I need to provide users a way to mark a record using data validation. But they also need to be able to unmark it (blank option).
Normally I would just tell them to hit “delete” to remove the selection. But since I expect them to run the file in sharepoint, that is not an option apparently.
The file I am creating for the users is created from a larger file, so pointing my data validation list to a range is not an option because that range is not distributed with the final file. So I need to create the data validation string in VBA.
This is the code to create the data validation field without a blank option (preferably first)
With Range("Q2:Q" & lrow).Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, _
Formula1:="Blue, ” & _
"Red," & _
"Yellow," & _
"Green”
.IgnoreBlank = False
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
This works fine
What I’ve tried -
I tried adding “ – ,”
Formula1:=” -- ,” & _
"Blue, ” & _
"Red," & _
"Yellow," & _
"Green”
That adds an option “—“ which I don’t want
I tried
Formula1:=Chr(160) & “, “ & _
"Blue, ” & _
"Red," & _
"Yellow," & _
"Green”
I get an error – With Chr highlighted - “Can’t find project or library”
Anyone have any ideas?
Thanks
Bookmarks