So my vba function should assign different values to a cell based on a boolean input. True part works perfectly, however I'm getting stuck with the False statement. The True part assigns a drop down list to the cell, and the False part should erase it, and set its value to text "N/A". As soon as I'm trying to change the value of the cell (or any cells actually, with range("..").value command, the code faces an error.
Is there an other way around? Thanks in advance!
Function sema_list(rng As Range, sema As Boolean)
If sema = True Then
With rng.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=arrangement"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
If sema = False Then
rng.Validation.Delete
rng.Value = "some text"
End If
sema_list = ""
End Function