Hi,
I'm trying to use validation to add a list to a cell, I'm not sure if maybe I'm using the cell area incorrectly or what, but it doesn't throw any errors, and does not populate the list
I am using the following code:
Dim validations As Validations = designer.Workbook.Worksheets(0).Validations
'Creating a Validation object
Dim validation As Validation = validations(validations.Add)
'Setting the validation type to whole number
validation.Type = ValidationType.List
'Setting the operator for validation to Between
validation.Operator = OperatorType.Between
'Setting the minimum value for the validation
validation.Formula1 = "=$C$2:$C$4"
'Applying the validation to a range of cells from A1 to B2 using the
'CellArea structure
Dim area As CellArea
area.StartRow = 7
area.EndRow = 7
area.StartColumn = 2
area.EndColumn = 2
'Adding the cell area to Validation
validation.AreaList.Add(area)
I've attached my spreadsheet
Hi,
I think the problem is with the smart markers you have used in the file.
Could you please test and populate the list with a simple file and not with the smart markers template file. I think you can add a validation list to the cell and fill it with data.
We will check it and resolve the issue soon.
Thanks
Regards
Amjad Sahi
Aspose Nanjing Team
'Applying the validation to a range of cells from A1 to B2 using the
'CellArea structure
Dim area As CellArea
area.StartRow = 7
area.EndRow = 7
area.StartColumn = 2
area.EndColumn = 2
Your code applies the validation to cell C8, not from A1 to B2. In cell C8, you have already apply a validation on it, right?
To apply it to A1-B2, please change your code to:
Dim validations As Validations = designer.Workbook.Worksheets(0).Validations
'Creating a Validation object
Dim validation As Validation = validations(validations.Add)
'Setting the validation type to whole number
validation.Type = ValidationType.List
'Setting the operator for validation to Between
validation.Operator = OperatorType.Between
'Setting the minimum value for the validation
validation.Formula1 = "=$C$2:$C$4"
'Applying the validation to a range of cells from A1 to B2 using the
'CellArea structure
Dim area As CellArea
area.StartRow = 0
area.EndRow = 1
area.StartColumn = 0
area.EndColumn = 1
'Adding the cell area to Validation
validation.AreaList.Add(area)
However, from your output file, I see that cell A1 to C3 is merged. So above code also may not work for you. Could you please post a file to show your expected output? Thank you.