Computer >> คอมพิวเตอร์ >  >> ซอฟต์แวร์ >> Office

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

ใน Microsoft Excel เครื่องมือที่จำเป็นมากมายจะสร้างประสบการณ์การใช้งานที่ยอดเยี่ยมให้กับผู้ใช้ หนึ่งในนั้นคือเครื่องมือเลือกวันที่ ด้วยเครื่องมือนี้ คุณสามารถแทรกวันที่และเวลาใดก็ได้ ในแผ่นงาน มันปรากฏขึ้นเหมือน ปฏิทิน . คุณสามารถเลือก วันที่ จากนั้น. ในบทช่วยสอนนี้ คุณจะได้เรียนรู้การแทรกตัวเลือกวันที่ใน Excel พร้อมตัวอย่างและภาพประกอบที่เหมาะสม รายละเอียดมากมายกำลังมาในตอนหลัง ดังนั้นฉันหวังว่าคุณจะคอยติดตาม

เหตุใดเครื่องมือเลือกวันที่จึงมีประโยชน์ใน Excel

ตอนนี้ผู้คนชอบที่จะทำงานกับส่วนต่อประสานผู้ใช้ มันช่วยลดความเครียดในการทำงานของคุณ เราจะใส่วันที่อย่างไร ในเซลล์? โดยการพิมพ์ลงในเซลล์ใช่ไหม เราทุกคนรู้ว่าการพิมพ์เป็นเรื่องที่น่าตื่นเต้น ถ้าคุณมี 500 แถวในชุดข้อมูลล่ะ คุณไม่ต้องการแทรกวันที่ทั้งหมดด้วยตนเองใน Excel!

เครื่องมือเลือกวันที่มาช่วยเราที่นี่ เป็นปฏิทินป๊อปอัปที่คุณสามารถใช้เพื่อแทรกวันที่ และควบคุมพวกเขา ดูภาพหน้าจอต่อไปนี้:

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

คุณสามารถดูตัวเลือกวันที่ได้ที่นี่ ด้วยเครื่องมือนี้ คุณสามารถเลือกวันที่และดำเนินการใดๆ ใน Microsoft Excel ได้

คำแนะนำทีละขั้นตอนในการแทรกตัวเลือกวันที่ใน Excel

ในส่วนต่อไปนี้ เราจะให้คำแนะนำทีละขั้นตอนในการแทรกตัวเลือกวันที่ใน Excel เราขอแนะนำให้คุณดูและเรียนรู้ขั้นตอนเหล่านี้ทั้งหมดอย่างใกล้ชิด มันจะพัฒนาความรู้ Excel ของคุณได้อย่างชัดเจน

1. เปิดใช้งานแท็บนักพัฒนาใน Excel สำหรับตัวเลือกวันที่

ก่อนอื่น เครื่องมือเลือกวันที่นี้มีให้เฉพาะใน นักพัฒนา แท็บ ดังนั้น ก่อนที่คุณจะเริ่ม คุณต้องเปิดใช้งานแท็บนักพัฒนาซอฟต์แวร์ใน Microsoft Excel

มาเปิดใช้งานแท็บนักพัฒนาซอฟต์แวร์กันก่อน

📌 ขั้นตอน

  • ขั้นแรก ให้คลิกที่ ไฟล์  แท็บ
  • ถัดไป คลิกที่ ตัวเลือก .

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • ตอนนี้ จากตัวเลือก Excel กล่องโต้ตอบ ให้คลิกที่กำหนด Ribbon เอง ทางด้านซ้ายมือ

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • จากด้านขวาของหน้าต่าง ให้เลือก แท็บหลัก .
  • สุดท้าย ให้ตรวจสอบ ผู้พัฒนา  กล่อง.

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

ดังที่คุณเห็นจากริบบอน Excel เราสามารถแทรกแท็บนักพัฒนาซอฟต์แวร์ใน Microsoft Excel ได้สำเร็จ

อ่านเพิ่มเติม: วิธีแทรกวันและวันที่ใน Excel (3 วิธี)

2. แทรกตัวเลือกวันที่

ถึงเวลาที่จะแทรกตัวเลือกวันที่ในเวิร์กชีต ทำตามขั้นตอนเหล่านี้เพื่อทำสิ่งนั้น

📌 ขั้นตอน

  • ขั้นแรก ไปที่ ผู้พัฒนา  แท็บ
  • จาก การควบคุม ให้คลิกที่ แทรก .

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • จาก การควบคุม ActiveX ให้คลิกที่ การควบคุมเพิ่มเติม

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • ตอนนี้ เลือก Microsoft Date and Time Picker Control 6.0 (SP6) จากการควบคุมเพิ่มเติม กล่องโต้ตอบ

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • หลังจากนั้น คลิก ตกลง .
  • สุดท้าย ให้คลิกเซลล์ที่คุณต้องการแทรกตัวเลือกวันที่

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

อย่างที่คุณเห็น เราได้แทรกตัวควบคุมตัวเลือกวันที่ในเซลล์

เมื่อคุณแทรกตัวควบคุมตัวเลือกวันที่ในเวิร์กชีต คุณจะเห็น EMBEDDED สูตรในแถบสูตร

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

หมายถึงชนิดของการควบคุมที่ฝังอยู่ในเวิร์กชีตนี้ จำไว้ว่าคุณไม่สามารถเปลี่ยนแปลงได้ มันจะแสดง “การอ้างอิงไม่ถูกต้อง ” ผิดพลาดหากคุณทำเช่นนั้น

อ่านเพิ่มเติม: วิธีรวมวันที่และเวลาในเซลล์เดียวใน Excel (4 วิธี)

3. ปรับแต่งตัวเลือกวันที่

คุณสามารถเห็นการควบคุมตัวเลือกวันที่ของเราดูไม่ดีที่นี่ เราจึงต้องปรับแต่งเพื่อให้ดูดีขึ้น

เมื่อคุณแทรกตัวเลือกวันที่ โหมดการออกแบบจะเปิดใช้งานโดยอัตโนมัติ ช่วยให้คุณปรับเปลี่ยนได้ แน่นอนว่าเราจะทำอย่างนั้น เราจะปรับขนาดและเปลี่ยนคุณสมบัติบางอย่างด้วย

📌 ขั้นตอน

  • หากต้องการทำให้มันใหญ่ขึ้นหรือเล็กลง คุณสามารถลากตัวเลือกวันที่

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • ในขณะที่ การออกแบบ โหมดเปิดอยู่ ให้คลิกขวาที่ตัวเลือกวันที่ หลังจากนั้น คลิกที่ คุณสมบัติ .

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • ที่นี่ คุณจะเห็นตัวเลือกต่างๆ เราจะทำงานร่วมกับพวกเขาบางส่วน

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • คุณสามารถเปลี่ยนความสูง ความกว้าง แบบอักษร สี ฯลฯ
  • ตอนนี้ ให้ลากตัวเลือกวันที่ไปยังตำแหน่งของเซลล์ที่คุณต้องการวาง

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

ตอนนี้ เครื่องมือเลือกวันที่ของเราเกือบจะพร้อมแล้ว สิ่งที่เราต้องทำคือเชื่อมโยงปฏิทินกับเซลล์

อ่านเพิ่มเติม: วิธีแทรกวันที่ในส่วนท้ายใน Excel (3 วิธี)

4. เชื่อมโยงตัวควบคุมตัวเลือกวันที่กับเซลล์

คุณอาจคิดว่าเราได้แทรกไว้และสามารถดำเนินการตามขั้นตอนใด ๆ ในตอนนี้ แต่นี่คือการจับ คุณสามารถดำเนินการใดๆ ได้โดยไม่ต้องลิงก์ตัวเลือกวันที่กับเซลล์ Microsoft Excel จะไม่รู้จักวันที่ที่เกี่ยวข้องกับเซลล์ใดๆ โดยอัตโนมัติ จำไว้ว่าไม่มีสูตรใดทำงานหากไม่มีสิ่งนี้

📌 ขั้นตอน

  • ขั้นแรก ให้คลิกขวาที่ตัวเลือกวันที่

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • จากเมนูตามบริบท ให้คลิกที่ คุณสมบัติ .

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • ตอนนี้ ใน เซลล์ที่เชื่อมโยง ให้พิมพ์การอ้างอิงเซลล์ที่คุณต้องการเชื่อมต่อ

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • เมื่อคุณเลือกวันที่จากปฏิทิน คุณจะเห็นวันที่ในเซลล์ที่ลิงก์โดยอัตโนมัติ คลิกที่ ตกลง ถ้า Excel แสดง “ไม่สามารถตั้งค่าเซลล์เป็น NULL… ” ความผิดพลาด
  • หากต้องการยอมรับค่า Null ให้เปลี่ยนค่าจาก FALSE เป็น จริง ใน ช่องทำเครื่องหมาย

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • หากคุณคลิกขวาที่ตัวเลือกวันที่แล้วคลิก ดูรหัส คุณจะเห็นรหัส VBA ที่เกี่ยวข้อง

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

อ่านเพิ่มเติม: Excel ป้อนวันที่โดยอัตโนมัติเมื่อป้อนข้อมูล (7 วิธีง่ายๆ)

วิธีการแทรกตัวเลือกวันที่บนทั้งคอลัมน์ใน Excel

สิ่งที่เราทำจนถึงตอนนี้คือการแทรกตัวเลือกวันที่ในเซลล์ เราสามารถแทรกตัวเลือกวันที่ในช่วงของเซลล์หรือคอลัมน์เฉพาะ เมื่อใดก็ตามที่คุณคลิกที่เซลล์ ปฏิทินจะปรากฏขึ้นและคุณสามารถเลือกวันที่ได้จากที่นั่น ในส่วนต่อไปนี้ เราจะแสดงให้คุณแทรกทั้งคอลัมน์เดี่ยวและหลายคอลัมน์

1. แทรกตัวเลือกวันที่สำหรับคอลัมน์เดียว

📌 ขั้นตอน

  • หากต้องการกำหนดตัวเลือกวันที่สำหรับทั้งคอลัมน์ ให้คลิกขวาที่ตัวเลือกวันที่ หลังจากนั้น คลิกที่ ดูโค้ด .

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

  • หลังจากนั้น คุณจะเห็นโค้ดบางส่วนหากคุณได้ปรับแต่งมัน
  • ตอนนี้ ล้าง VBA รหัสและพิมพ์รหัสต่อไปนี้ที่เรากำลังแสดงที่นี่:
Sub Worksheet_SelectionChange(ByVal Target As Range)
 
 With Sheet1.DTPicker1
 .Height = 20 
 .Width = 20 
 If Not Intersect(Target, Range("B:B")) Is Nothing Then 
 .Visible = True 
 .Top = Target.Top 
 .Left = Target.Offset(0, 1).Left 
 .LinkedCell = Target.Address 
 Else 
 .Visible = False 
 End If 
 End With 
 
End Sub

This code basically sets column B as a date picker.

  • Now, deselect the Design mode.
  • After that, click on any cell to remove the Date Picker.
  • Now, click on any cell of column B . You will see date picker control from every cell.

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

Code Explanations:

 With Sheet1.DTPicker1
 .Height = 20 
 .Width = 20 

This code demonstrates the sheet number (Remember your sheet number even if you have changed the name) and the date picker number. Here, we have sheet1(Basic Datepicker sheet)  and date picker 1. Height and width that you set manually.

 If Not Intersect(Target, Range("B:B")) Is Nothing Then 
 .Visible = True 

This code demonstrates that if any cell of column B is selected, the date picker will be visible. Or you can set a custom range like Range(“B5:B14”) . It will set the date picker only for those particular cells in column B .

 .Top = Target.Top 
 .Left = Target.Offset(0, 1).Left 
 .LinkedCell = Target.Address 

The “top ” property basically means it proceeds along with the upper border of the designated cell. It is equivalent to the “top” belongings value of the specified cell.

  The “Left ” property is equivalent to the next right cell (of the cell that you specified). It is the length of the left border from the outer left of the worksheet. We used the offset function to get the cell reference of the right cell.

LinkedCell ” connects the date picker with the target cell. When we select the date from the dropdown, it allows that in the cell.

 Else 
 .Visible = False 

When you select any other cell rather than a cell of column C , the date picker won’t show up.

2. Insert Date Picker for Multiple Columns

Now, if you want to set multiple columns with a date picker, you have to make a simple change. Remember, before you set multiple columns with date pickers, you have to insert another date pickers again.

If you want to set a date picker for adjacent columns, you don’t have to write another code segment. Just change in the IF segment:

If Not Intersect(Target, Range("C:D")) Is Nothing Then

Now, the following code will set a date picker for columns B, D, E, G:

Here, we are not assigning the date picker in the entire column. Rather than, we are inserting it in a range of cells. Date picker 1 for B5:B14, Date picker 2 for D5:E14, and Date picker 3 for G5:G14.

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 

 With Sheet1.DTPicker1 
 .Height = 20 
 .Width = 20 
 If Not Intersect(Target, Range("B5:B14")) Is Nothing Then
 .Visible = True
 .Top = Target.Top
 .Left = Target.Offset(0, 1).Left
 .LinkedCell = Target.Address
 Else
 .Visible = False
 End If
 End With

 With Sheet1.DTPicker2 
 .Height = 20 
 .Width = 20 
 If Not Intersect(Target, Range("D5:E14")) Is Nothing Then
 .Visible = True
 .Top = Target.Top
 .Left = Target.Offset(0, 1).Left
 .LinkedCell = Target.Address
 Else
 .Visible = False
 End If
 End With

 With Sheet1.DTPicker3 
 .Height = 20 
 .Width = 20 
 If Not Intersect(Target, Range("H5:H14")) Is Nothing Then
 .Visible = True
 .Top = Target.Top
 .Left = Target.Offset(0, 1).Left
 .LinkedCell = Target.Address
 Else
 .Visible = False
 End If
 End With
 
End Sub

Look here, we have three date pickers here. One for column B , one for columns D and E combined, and another one for column G . After clicking each cell of these columns you will see a calendar. In this way, you can insert a date picker for multiple columns in Excel.

วิธีการแทรกตัวเลือกวันที่ใน Excel (ด้วยขั้นตอนทีละขั้นตอน)

Big Issue With the Date Picker in Excel

If you are using 64 bit of any Microsoft Excel software or you are using Excel 365 or Excel 2019, you are already confused by now. It is because you couldn’t find the date picker in the ActiveX control.

We are sorry to say Microsoft’s Date Picker control is only available in 32-bit versions of Excel 2016, Excel 2013, and Excel 2010, but it won’t work on Excel 64-bit. So, if you really want to insert a calendar in your worksheet, use any third-party calendar. I hope Microsoft will bring some kind of date picker in the future.

💬 Things to Remember

Make sure to link the date picker with a cell if you are working with one.

Your file should be saved as a Macro-Enabled Workbook (.xlsm).

To make any change to the date picker, make sure to select it from the developer tab.

To see changes from VBA codes, deselect the date picker.

บทสรุป

To conclude, I hope this tutorial has provided you with a piece of useful knowledge to insert a date picker in Excel. We recommend you learn and apply all these instructions to your dataset. Download the practice workbook and try these yourself. Also, feel free to give feedback in the comment section. Your valuable feedback keeps us motivated to create tutorials like this.

Don’t forget to check our website Exceldemy.com for various Excel-related problems and solutions.

Keep learning new methods and keep growing!

บทความที่เกี่ยวข้อง

  • How to Display Day of Week from Date in Excel (8 Ways)
  • Insert Last Saved Date in Excel (4 Examples)
  • How to Enter Time in Excel (5 Methods)
  • Change Dates Automatically Using Formula in Excel
  • How to auto populate date in Excel when cell is updated