excel导入数据校验_通过Excel数据验证获得良好日期

excel导入数据校验

image

There's a story making the rounds, about a guy who rated all his online dating prospects, by using an Excel worksheet.

有一个故事四处传播,一个人通过使用Excel工作表对他的所有在线约会前景进行了评级。

While I'm sure we could all learn a thing or two from that guy's file, this article is about a different kind of dates – calendar dates.

虽然我敢肯定我们都可以从那个人的档案中学到一两个东西,但是本文是关于另一种日期的-日历日期。

Calendar dates might not be as exciting, but unlike romantic dates, you can use data validation to help keep them under control in Excel.

日历日期可能不那么令人兴奋,但与浪漫的日期不同,您可以使用数据验证来帮助使其在Excel中得到控制。

输入期间结束日期 (Entering Period End Dates)

Last week in the Daily Dose of Excel blog, Dick Kusleika was looking for a more efficient way to enter a Period Ending date in his time sheet. Every two weeks he sets up a new workbook, and has to add two weeks to the previous end date.

上周,在Excel的每日剂量博客中,迪克·库斯莱卡(Dick Kusleika)正在寻找一种更有效的方式来在时间表中输入“ 期末”日期 。 他每两周设置一次新的工作簿,并且必须在上一个结束日期之前增加两周。

Sometimes it's easy to do that kind of math in your head, but if you're rolling into a new month, the calculation can be trickier. So, Dick changed the date cell to a formula, and just added 14 to that calculation every two weeks.

有时候,脑海中进行这种数学运算很容易,但是如果您要进入一个新的月,计算可能会比较棘手。 因此,迪克将日期单元格更改为一个公式,并且每两周将14加到该计算中。

image

There were a few suggestions for solving the problem, but Dick wanted something simple and static -- the date cell couldn't change, if you opened the file on a different date.

有一些解决问题的建议,但是Dick想要一些简单而静态的东西-如果您在其他日期打开文件,则日期单元不能更改。

创建动态日期列表 (Create a Dynamic List of Dates)

My suggestion was to create a drop down list of Period End dates, and select the next date from that list. With some formulas in the background, the list of valid dates would update automatically. However, when you select one of those dates in the Period End cell, it's a static entry in that cell.

我的建议是创建一个“期间结束日期” 下拉列表 ,然后从该列表中选择下一个日期。 在后台使用某些公式的情况下,有效日期列表将自动更新。 但是,当您在“周期结束”单元格中选择这些日期之一时,它是该单元格中的静态条目。

The first step is to create the list of dates, based on Dick's original Period End date – October 13, 2010.

第一步是根据Dick的原始“期末”日期-2010年10月13日创建日期列表。

  • On Sheet2, put the starting date in cell C2: =DATE(2010,8,13)

    在Sheet2上,将开始日期放在单元格C2中: = DATE(2010,8,13)

  • In cell C3, enter a formula to calculate the current date: =TODAY()

    在单元格C3中,输入一个公式以计算当前日期: = TODAY()

  • In C6, enter this formula, to calculate the current pay period's week end:

    在C6中,输入以下公式,以计算当前工资期的周末:

    =C2+INT((C3-C2)/14)*14

    = C2 + INT((C3-C2)/ 14)* 14

datavalidationdates16
  • In C5, subtract 14 days, to calculate the previous period end date: =C6-14

    在C5中,减去14天,以计算上一个期间的结束日期: = C6-14

  • In C7, add 14 days, to calculate the next period end date: =C6+14

    在C7中,添加14天,以计算下一个期间的结束日期: = C6 + 14

命名日期列表 (Name the Date List)

Next, you'll name the date list, so you can use it in a data validation drop down.

接下来,您将命名日期列表,以便可以在数据验证下拉列表中使用它。

  • Select cells C5:C7, and click in the Name Box, to the left of the Formula bar

    选择单元格C5:C7,然后单击“公式”栏左侧的“名称框”
  • Type a one-word name for the list – DateList – and press the Enter key.

    为列表键入一个单词名称– DateList –并按Enter键。

创建日期下拉列表 (Create the Drop Down List of Dates)

Back on the Time Sheet, you'll add a data validation drop down list in the date cell.

返回时间表,您将在日期单元格中添加一个数据验证下拉列表。

  • On the Time Sheet, select the Period End date cell.

    在时间表上,选择“期末日期”单元格。
  • On the Excel Ribbon, click the Data tab, and click Data Validation.

    在Excel功能区上,单击“数据”选项卡,然后单击“数据验证”。
  • From the Allow drop down, click on List

    从“允许”下拉列表中,单击“列表”。
  • In the Source box, type an equal sign and the list's name: =DateList

    在“源”框中,键入一个等号和列表的名称: = DateList

  • Click OK to close the data validation dialog box.

    单击“确定”关闭数据验证对话框。
datavalidationdates13

测试日期下拉列表 (Test the Drop Down List of Dates)

On the Time Sheet, the Period End date cell now has a drop down arrow.

在时间表上,“期间结束日期”单元格现在具有一个下拉箭头。

  • Click the arrow, to see the current list of dates, and click on a date to select it.

    单击箭头,查看当前日期列表,然后单击日期以将其选中。
datavalidationdates18

The selected date is entered in the cell, as a value, not a formula. Even when the list of dates changes, the selected date will not be affected.

所选日期作为值而不是公式输入到单元格中。 即使日期列表更改,所选日期也不会受到影响。

更多例子 (More Examples)

Please visit the Contextures website for more examples of Excel Data Validation for dates.

请访问Contextures网站,以获取有关日期的Excel数据验证的更多示例

翻译自: https://contexturesblog.com/archives/2012/04/24/get-good-dates-with-excel-data-validation/

excel导入数据校验

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值