priya
priya

Reputation: 26759

How to mark a cell value as mandatory

How to mark a cell value as mandatory in excel. I have a sheet which contains 3 headers and I would like to mark the column values of header3 as mandatory from a possible set of values (i.e. even if the user doesn't select a value a default value should be set for the cell)

Upvotes: 0

Views: 549

Answers (2)

Rohit Agrawal
Rohit Agrawal

Reputation: 483

If You want to do with the help of c# code Try this : -

Worksheet ws;
Range oRng = ws.get_Range(StartCol + StartRow, EndCol + EndRow);
oRng.Validation.Add(XlDVType.xlValidateDecimal, XlDVAlertStyle.xlValidAlertStop, XlFormatConditionOperator.xlBetween, "StartVal", "EndVal");
                                oRng.Validation.IgnoreBlank = true;
                                oRng.Validation.InCellDropdown = true;
                                oRng.Validation.ErrorTitle = "Input Error";
                                oRng.Validation.ErrorMessage = "Please enter a numeric

value between "StartVal" and "EndVal""; oRng.Validation.ShowError = true;

where ws is the worksheet object, StartVal and EndVal are the range of values for which validation is to be checked

Upvotes: 0

Yograj Gupta
Yograj Gupta

Reputation: 9869

Use Validation on Cells where you want to perform these constraints.

Like : Select Range of Cells where you want to put this constraint.

Now open Data Validation Dialog and Select List from Allow drop down in Setting Tab. Provide your source (possible values) in comma separate values

Upvotes: 1

Related Questions