Excel - 如何限制数据验证列表的值更改为日期 [英] Excel - how to restrict values of data validation list changing to date
本文介绍了Excel - 如何限制数据验证列表的值更改为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
We are creating a data validation list from C# code. This list will contain Month with year. How can we restrict excel from converting this list from changing to date format?
Below is the code:
range.Validation.Add(XlDVType.xlValidateList,
XlDVAlertStyle.xlValidAlertInformation,
XlFormatConditionOperator.xlBetween,
flatList,
Type.Missing);
range.Validation.IgnoreBlank = false;
range.Validation.InCellDropdown = true;
flatList will have values "June 2016, July 2016, August 2016". Excel converts the list to "Jun-2016, Jul-2016, Aug-2016". We want that to be avoided and the list should remain as text.
Please advice.
我尝试过的事情:
尝试将单元格格式设为文本但没有运气。
What I have tried:
Tried making the cell format as text but no luck.
推荐答案
尝试将撇号(单引号)'设为flatList中条目的开头......
'2016年6月,2016年7月,2016年8月等等
或者,如果你使用的是命名区域,每个区域都在一个单独的单元格中:
'2016年6月
'2016年7月
'2016年8月
Try putting an apostrophe (single quote) ' at the beginning of the entries in flatList...
'June 2016, 'July 2016, 'August 2016, etc.
or, if you're using a named range where each one is in a separate cell:
'June 2016
'July 2016
'August 2016
这篇关于Excel - 如何限制数据验证列表的值更改为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文