天天看點

excel導入資料校驗_通過Excel資料驗證獲得良好日期

excel導入資料校驗

excel導入資料校驗_通過Excel資料驗證獲得良好日期

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加到該計算中。

excel導入資料校驗_通過Excel資料驗證獲得良好日期

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

excel導入資料校驗_通過Excel資料驗證獲得良好日期
  • 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.

    單擊“确定”關閉資料驗證對話框。

excel導入資料校驗_通過Excel資料驗證獲得良好日期

測試日期下拉清單 (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.

    單擊箭頭,檢視目前日期清單,然後單擊日期以将其選中。

excel導入資料校驗_通過Excel資料驗證獲得良好日期

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導入資料校驗