0
Answer

How to use INDIRECT() as a source in Validation.Add() in C#?

Nantha Kishor

Nantha Kishor

8y
428
1

0down votefavorite

I am actually trying to create a dependent drop down in excel using C#. Example: If we have two drop down columns named 'Country' and 'State' in excel. Based on the 'Country' chosen 'State' column drop down values will be populated.

In excel I have done this using data validation.

I can apply it in excel using C# as well except this INDIRECT(J2) as follows:

    xlWorkSheet.Range["K2:K10"].Validation.Add(Excel.XlDVType.xlValidateList, Type.Missing, Excel.XlFormatConditionOperator.xlBetween, Countries);

In the above code Countries is a string separated by comma. It is actually working fine. But how to write a code for INDIRECT(J2) to be replicated in the Source box of Data Validation as follows:

enter image description here

Any help would be appreciated.