Hi,
Create a Macro, look at the source code, look at the Microsoft documention, implement it in MATLAB:
VBA:
With Selection.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="1;2;3;4"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
Microsoft:
Combine these and you get the MATLAB part:
ex = actxserver('excel.application');
ex.visible = 1
wb = ex.workbooks.Add
ex.Range('A1').Select
ex.Selection.Validation.Delete;
ex.Selection.Validation.Add('xlValidateList',1,1,'1;2;3;4')
Important: First delete the Validation, otherwise you get an error if there is already a Validation created. And even more important, you have to work with the enum values for the second and third argument. With the enum strings it doesn't work. (I guess they are ordered like in the Microsoft link above, so simply count to get the correct number^^)