visual studio - How to apply data validation for drop down in excel sheet by C# code -
i working on excel plugin , trying create dropdowns column can have column cells data.
for example:
column h's name type
, has data "animal, human".
column i's name animal
, has data "dog, cat, rat"
column j's name dog
, has data "dog1, dog2, dog3"
column k's name cat
, has data "cat1 , cat2 , cat3"
column l's name rat
, has data "rat1 , rat2 , rat3"
1 h j k l 2 type name dog cat rat 3 animal dog dog1 cat1 rat1 4 human cat dog2 cat2 rat2 5 rat dog3 cat3 rat3
i linked column column h formula:
firstrow.validation.add(excel.xldvtype.xlvalidatelist, excel.xldvalertstyle.xlvalidalertstop, excel.xlformatconditionoperator.xlbetween, "=" + activeworksheet.name + "!" + activeworksheet.get_range("type").addresslocal);
same formula applied b2
changing range name.
now cell a1
has dropdown list of "animal, human".
cell b1
's dropdown list dependent on cell a1
.
so if user selecting a1
data "animal", dropdown list of b1
should according a1
's dropdown data "dog, cat, rat, lion"
again if user selecting d1
, should according selected data b1
.
in excel selected cells , go data validation tab, select type list , applied formula like:
=indirect($a1)
and working fine column b1
.
how can apply c# code.?
please let me know if sentence not clear.
Comments
Post a Comment