ไปยังเนื้อหาหลัก

จะแทรกวันที่แก้ไขล่าสุดในส่วนหัวหรือส่วนท้ายของ Excel ได้อย่างไร?

ใน Excel เราสามารถแทรกข้อมูลเวิร์กบุ๊กเช่นชื่อไฟล์เส้นทางแบบเต็มของไฟล์วันที่ปัจจุบันและอื่น ๆ ลงในส่วนหัวหรือส่วนท้ายได้อย่างรวดเร็วและง่ายดาย แต่คุณเคยพยายามแทรกวันที่และเวลาที่แก้ไขล่าสุดของแผ่นงานลงในหรือไม่? Excel ไม่มีคุณลักษณะนี้ให้เราใส่วันที่แก้ไขล่าสุดในส่วนหัวหรือส่วนท้ายและที่นี่ฉันจะแนะนำวิธีที่สะดวกในการแก้ปัญหา

แทรกวันที่แก้ไขล่าสุดในส่วนหัวหรือส่วนท้ายของ Excel ด้วยรหัส VBA

แทรกวันที่แก้ไขล่าสุด / วันที่สร้าง / ใช้ส่วนหัว / ท้ายกระดาษด้วย Kutools for Excel ความคิดที่ดี 3


ลูกศรสีฟ้าฟองขวา แทรกวันที่แก้ไขล่าสุดในส่วนหัวหรือส่วนท้ายของ Excel ด้วยรหัส VBA

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

1. เปิดใช้งานแผ่นงานของคุณที่คุณต้องการแทรกวันที่แก้ไขล่าสุดลงในส่วนหัวหรือส่วนท้าย

2. จากนั้นกดปุ่ม ALT + F11 คีย์เพื่อเปิด หน้าต่าง Microsoft Visual Basic for Applications.

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

รหัส VBA: แทรกวันที่แก้ไขล่าสุดในส่วนหัวหรือส่วนท้าย

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveSheet.PageSetup.CenterHeader = "Last saved: " & Format(Date, "mm-dd-yy") & " " & Time
End Sub

doc-insert-last-save-date-to-header-1

4. จากนั้นบันทึกและปิดรหัสนี้และไปที่คลิก รายละเอียด > เค้าโครงหน้ากระดาษ เพื่อดูผลลัพธ์ และคุณสามารถดูวันที่และเวลาที่แก้ไขล่าสุดได้ถูกแทรกลงในส่วนหัวตรงกลาง ดูภาพหน้าจอ:

doc-insert-last-save-date-to-header-2
-1
doc-insert-last-save-date-to-header-3

หมายเหตุ:

1. วันที่และเวลาที่แก้ไขล่าสุดจะอัปเดตโดยอัตโนมัติเมื่อคุณแก้ไขและบันทึกไฟล์ Excel

2. หากคุณต้องการแทรกวันที่และเวลาที่บันทึกไว้ล่าสุดนี้ลงในส่วนหัว / ส่วนท้ายด้านซ้ายส่วนหัว / ส่วนท้ายด้านขวาหรือส่วนท้ายตรงกลางคุณเพียงแค่ต้องเปลี่ยน CenterHeader ในโค้ดด้านบนตามคำขอของคุณ


ลูกศรสีฟ้าฟองขวา แทรกวันที่แก้ไขล่าสุด / วันที่สร้าง / ใช้ส่วนหัว / ท้ายกระดาษด้วย Kutools for Excel

ด้วย Kutools for Excel คุณสามารถใช้เครื่องมือแทรกข้อมูลสมุดงานเพื่อแทรกข้อมูลสมุดงานลงในส่วนหัวส่วนท้ายหรือเซลล์ได้อย่างรวดเร็ว

Kutools สำหรับ Excel, ที่มีมากกว่า 300 ฟังก์ชั่นที่มีประโยชน์ทำให้งานของคุณง่ายขึ้น 

หลังจากการติดตั้ง Kutools สำหรับ Excel โปรดทำดังนี้ :(ดาวน์โหลด Kutools for Excel ได้ฟรีทันที!)

คลิก Kutools พลัส > สมุดงาน >แทรกข้อมูลสมุดงานและในกล่องโต้ตอบ popping ให้ตรวจสอบข้อมูลที่คุณต้องการแทรกแล้วไปที่ แทรกที่ ตรวจสอบ พิสัย, ส่วนหัว or ฟุตบอล และระบุให้แทรกที่ส่วนหัว / ส่วนท้ายด้านซ้ายส่วนหัว / ส่วนท้ายตรงกลางหรือส่วนหัว / ส่วนท้ายด้านขวาเพื่อตอบสนองความต้องการของคุณ
doc แทรกข้อมูลสมุดงาน
doc แทรกข้อมูลสมุดงาน

ลูกศรสีฟ้าฟองขวา แทรกข้อมูลสมุดงาน


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

รับและแทรกเวลาที่สร้างขึ้นและเวลาที่แก้ไขล่าสุดในเซลล์

สุดยอดเครื่องมือเพิ่มผลผลิตในสำนักงาน

🤖 Kutools AI ผู้ช่วย: ปฏิวัติการวิเคราะห์ข้อมูลโดยยึดตาม: การดำเนินการที่ชาญฉลาด   |  สร้างรหัส  |  สร้างสูตรที่กำหนดเอง  |  วิเคราะห์ข้อมูลและสร้างแผนภูมิ  |  เรียกใช้ฟังก์ชัน Kutools...
คุณสมบัติยอดนิยม: ค้นหา เน้น หรือระบุรายการที่ซ้ำกัน   |  ลบแถวว่าง   |  รวมคอลัมน์หรือเซลล์โดยไม่สูญเสียข้อมูล   |   รอบโดยไม่มีสูตร ...
การค้นหาขั้นสูง: VLookup หลายเกณฑ์    VLookup หลายค่า  |   VLookup ข้ามหลายแผ่น   |   การค้นหาที่ไม่ชัดเจน ....
รายการแบบเลื่อนลงขั้นสูง: สร้างรายการแบบหล่นลงอย่างรวดเร็ว   |  รายการแบบหล่นลงขึ้นอยู่กับ   |  เลือกหลายรายการแบบหล่นลง ....
ผู้จัดการคอลัมน์: เพิ่มจำนวนคอลัมน์เฉพาะ  |  ย้ายคอลัมน์  |  สลับสถานะการมองเห็นของคอลัมน์ที่ซ่อนอยู่  |  เปรียบเทียบช่วงและคอลัมน์ ...
คุณสมบัติเด่น: กริดโฟกัส   |  มุมมองการออกแบบ   |   บาร์สูตรใหญ่    สมุดงานและตัวจัดการชีต   |  ห้องสมุดทรัพยากร (ข้อความอัตโนมัติ)   |  เลือกวันที่   |  รวมแผ่นงาน   |  เข้ารหัส/ถอดรหัสเซลล์    ส่งอีเมลตามรายการ   |  ซุปเปอร์ฟิลเตอร์   |   ตัวกรองพิเศษ (กรองตัวหนา/ตัวเอียง/ขีดทับ...) ...
ชุดเครื่องมือ 15 อันดับแรก12 ข้อความ เครื่องมือ (เพิ่มข้อความ, ลบอักขระ, ... )   |   50 + แผนภูมิ ประเภท (แผนภูมิ Gantt, ... )   |   40+ ใช้งานได้จริง สูตร (คำนวณอายุตามวันเกิด, ... )   |   19 การแทรก เครื่องมือ (ใส่ QR Code, แทรกรูปภาพจากเส้นทาง, ... )   |   12 การแปลง เครื่องมือ (ตัวเลขเป็นคำ, การแปลงสกุลเงิน, ... )   |   7 ผสานและแยก เครื่องมือ (แถวรวมขั้นสูง, แยกเซลล์, ... )   |   ... และอื่น ๆ

เพิ่มพูนทักษะ Excel ของคุณด้วย Kutools สำหรับ Excel และสัมผัสประสิทธิภาพอย่างที่ไม่เคยมีมาก่อน Kutools สำหรับ Excel เสนอคุณสมบัติขั้นสูงมากกว่า 300 รายการเพื่อเพิ่มประสิทธิภาพและประหยัดเวลา  คลิกที่นี่เพื่อรับคุณสมบัติที่คุณต้องการมากที่สุด...

รายละเอียด


แท็บ Office นำอินเทอร์เฟซแบบแท็บมาที่ Office และทำให้งานของคุณง่ายขึ้นมาก

  • เปิดใช้งานการแก้ไขและอ่านแบบแท็บใน Word, Excel, PowerPoint, ผู้จัดพิมพ์, Access, Visio และโครงการ
  • เปิดและสร้างเอกสารหลายรายการในแท็บใหม่ของหน้าต่างเดียวกันแทนที่จะเป็นในหน้าต่างใหม่
  • เพิ่มประสิทธิภาพการทำงานของคุณ 50% และลดการคลิกเมาส์หลายร้อยครั้งให้คุณทุกวัน!
Comments (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Why do I have to load the VB code into 'ThisWorkBook' of the VBAproject for every new workbook created? I would think that if I loaded the VB code into 'ThisWorkBook' of VBAHOME (PERSONAL.XLSB) if would be retained and available cresting new workbooks
This comment was minimized by the moderator on the site
Just tried it after moving the center header to the left footer. Didn't work. What I saved at 1:20 pm still recorded as 1:00 pm. Your help would be most appreciated. BTW, my spreadsheet was created as Excel 2007, and I made changes at the library on Excel 2016. Generally, I can go back and forth between versions with no problems.
Also, I didn't realize my name would be published. Any chance of changing it to Nancy E.?
Many thanks!
This comment was minimized by the moderator on the site
THANK YOU! That was invaluable. Who'd believe that Microsoft would exclude such an important function! What about Word? Is it done the same way now?
This comment was minimized by the moderator on the site
Thanks for the Info.
This comment was minimized by the moderator on the site
perfect.very useful ;-)
This comment was minimized by the moderator on the site
I did this and it works. I saved the file as .xlsx and closed it. Now, when I open it, I open the VBA coding window but I am not able to find this chunk of code to edit it. I would like to play with location and remove time. Thank you.
This comment was minimized by the moderator on the site
@John R. When you get to the VBA coding window, on the left section of the screen you need to double-click "ThisWorkbook" to open the right section of the screen. Then in the right section (at the top) you need to select "Workbook" and "BeforeSave". That should hopefully show you the chunk of code that you're looking for.
This comment was minimized by the moderator on the site
I tried this technique but could only get it to show up on one sheet. Help?
This comment was minimized by the moderator on the site
Thanks! I maintain an employee phone number and extension list. People get hired, quit, move to different extensions. If someone wants a copy I print it off, but it only showed the date and time it was printed -- not necessarily the most current information. It was difficult to tell if you had two different copies which one was the most up-to-date. Showing the last time the file was saved will do what I wanted!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations