In a worksheet I have a table. In one of the columns there will be a code of 3 characters. Target is another column with data validation, based on the column with that code. Because I don't know what code will be entered, the formula in the validated column must be the same for the whole column.
In Excel it works fine. For each possible code I create a named range. After that, I use the following code in the List Datavalidation source for the whole column:
```
INDIRECT(INDIRECT(ADDRESS(ROW();1;3)))
```
The code I try to use:
```
Dim myValidat = mySheet.DataValidations.AddListValidation("A2:A7))
With myValidat
.ErrorStyle = OfficeOpenXml.DataValidation.ExcelDataValidationWarningStyle.warning
.ShowErrorMessage = True
.ShowInputMessage = True
.PromptTitle = "prompttitle"
.Prompt = "prompt"
.Formula.ExcelFormula = "INDIRECT(INDIRECT(ADDRESS(ROW();1;3)))"
End With
```
The first indirect is to get the value in the addressed cell.
The second indirect is to call the named range with the value in that cell
In Excel it works fine, but after using it in VB.NET and opening in Excel, that worksheet in that document is in errorstate, starts repairing, and delete the validation of that column.
In attachments you will find a working demo file. What I want is to accomplish this with code in VB.NET and using epplus. Please tell me what I'm doing wrong!
In Excel it works fine. For each possible code I create a named range. After that, I use the following code in the List Datavalidation source for the whole column:
```
INDIRECT(INDIRECT(ADDRESS(ROW();1;3)))
```
The code I try to use:
```
Dim myValidat = mySheet.DataValidations.AddListValidation("A2:A7))
With myValidat
.ErrorStyle = OfficeOpenXml.DataValidation.ExcelDataValidationWarningStyle.warning
.ShowErrorMessage = True
.ShowInputMessage = True
.PromptTitle = "prompttitle"
.Prompt = "prompt"
.Formula.ExcelFormula = "INDIRECT(INDIRECT(ADDRESS(ROW();1;3)))"
End With
```
The first indirect is to get the value in the addressed cell.
The second indirect is to call the named range with the value in that cell
In Excel it works fine, but after using it in VB.NET and opening in Excel, that worksheet in that document is in errorstate, starts repairing, and delete the validation of that column.
In attachments you will find a working demo file. What I want is to accomplish this with code in VB.NET and using epplus. Please tell me what I'm doing wrong!