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

วิธีทำให้ชื่อแท็บชีตเท่ากับค่าเซลล์ใน Excel

ในบางกรณีคุณอาจต้องเปลี่ยนชื่อแผ่นงานตามค่าเซลล์ที่ระบุ ในบทความนี้เราจะแสดงวิธีการสร้างชื่อแท็บแผ่นงานให้เท่ากับค่าเซลล์ใน Excel

ตั้งชื่อแท็บชีตให้เท่ากับค่าเซลล์ด้วยรหัส VBA
ตั้งชื่อแท็บชีตให้เท่ากับค่าเซลล์ด้วย Kutools for Excel


ตั้งชื่อแท็บชีตให้เท่ากับค่าเซลล์ด้วยรหัส VBA

ด้วยรหัส VBA ต่อไปนี้คุณสามารถตั้งชื่อแท็บแผ่นงานให้เท่ากับค่าเซลล์โดยอัตโนมัติ

1. คลิกขวาที่แท็บแผ่นงานที่คุณต้องการทำให้ชื่อแผ่นงานเท่ากับค่าเซลล์จากนั้นคลิก ดูรหัส จากเมนูคลิกขวา ดูภาพหน้าจอ:

2. คัดลอกและวางโค้ดด้านล่างลงในหน้าต่างรหัสจากนั้นกด อื่น ๆ + Q พร้อมกันเพื่อปิดหน้าต่าง Microsoft Visual Basic for Applications

รหัส VBA: สร้างแท็บแผ่นงานให้เท่ากับค่าเซลล์

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20230130
    On Error Resume Next
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        ActiveSheet.Name = ActiveSheet.Range("A1")
    ElseIf Not Intersect(Target.Dependents, Range("A1")) Then
        ActiveSheet.Name = ActiveSheet.Range("A1")
    End If
End Sub

หมายเหตุ: ในโค้ด A1 คือเซลล์ที่มีค่าที่คุณต้องใช้เป็นชื่อแผ่นงาน คุณสามารถเปลี่ยนได้ตามต้องการ

จากนี้ไปเมื่อค่าในเซลล์ A1 เปลี่ยนไปชื่อแท็บแผ่นงานก็จะเปลี่ยนไปอย่างเท่าเทียมกันเช่นกัน


ตั้งชื่อแท็บชีตให้เท่ากับค่าเซลล์ด้วย Kutools for Excel

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

ก่อนที่จะใช้ Kutools สำหรับ Excelโปรด ดาวน์โหลดและติดตั้งในตอนแรก.

1 คลิก Kutools พลัส > แผ่นงาน > เปลี่ยนชื่อแผ่นงานหลายแผ่น. ดูภาพหน้าจอ:

2 ใน เปลี่ยนชื่อแผ่นงานหลายแผ่น คุณต้องทำดังนี้

1). ตรวจสอบชื่อแผ่นงานที่คุณต้องการเปลี่ยนชื่อในไฟล์ แผ่น กล่อง (คุณสามารถเลือกหนึ่งแผ่นหรือหลายแผ่นก็ได้)
2). เลือก แทนที่ชื่อแผ่นงานต้นฉบับ กล่องใน เปลี่ยนชื่อตัวเลือก มาตรา.
3). หากคุณต้องการเปลี่ยนชื่อแผ่นงานหรือแผ่นงานหลายแผ่นด้วยค่าของเซลล์ที่ระบุโปรดเลือกไฟล์ จากช่วงเฉพาะ และเลือกช่วงของเซลล์ที่คุณต้องการเปลี่ยนชื่อแผ่นงานตาม
4). คลิก OK ปุ่ม. ดูภาพหน้าจอ:

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

หมายเหตุ / รายละเอียดเพิ่มเติม:

1 คุณสามารถใช้ ตัวกรอง ฟังก์ชันเพื่อกรองเวิร์กชีตที่ต้องการได้อย่างง่ายดายหากมีเวิร์กชีตอยู่มากมาย
2. ถ้าคุณต้องการเปลี่ยนชื่อแผ่นงานหลายแผ่นด้วยค่าเซลล์ที่แน่นอนในแต่ละแผ่นงาน ตัวอย่างเช่น sheet1 จะเท่ากับค่าของเซลล์ A1 และ sheet2 จะเท่ากับค่าของเซลล์ A1 ด้วย โปรดเลือกแผ่นงานในไฟล์ แผ่น จากนั้นเลือกไฟล์ เปลี่ยนชื่อแผ่นงานด้วยเซลล์เฉพาะ และระบุเซลล์ A1 ในช่อง

3. ชื่อแผ่นงานจะไม่เปลี่ยนโดยอัตโนมัติเมื่อมีการเปลี่ยนแปลงค่าของเซลล์

  หากคุณต้องการทดลองใช้ยูทิลิตีนี้ฟรี (30 วัน) กรุณาคลิกเพื่อดาวน์โหลดแล้วไปใช้การดำเนินการตามขั้นตอนข้างต้น


ตั้งชื่อแท็บชีตให้เท่ากับค่าเซลล์ด้วย Kutools for Excel

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

🤖 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 (30)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Good
It was the same thing I was looking for. But now I have a question:
After these steps were done, I created several sheets, I locked the sheet, but when I lock the book and enter a value in the cell, the name of the sheet does not change. In other words, it only changes with the spreadsheet unlocked and I would like to keep the spreadsheet locked
This comment was minimized by the moderator on the site
Boas
Era mesmo isto que estava a procurar. Mas agora tenho uma questão:
Após esses passos feitos, criei várias sheet, bloqueei a folha, mas quando bloqueio o livro e digito um valor na célula, o nome da sheet não muda. Ou seja, só muda com a sheet desbloqueada e gostaria de manter a sheet bloqueada
This comment was minimized by the moderator on the site
bonjour,
que voulez-vous dire par appuyer autre autre+q dans le code vba après avoir collé.
J'ai simplement fermé la page après avoir collé et ça ne marche pas
merci
This comment was minimized by the moderator on the site
worked beautifully!
This comment was minimized by the moderator on the site
Hi Crystal,

When i paste in your code it comes back with error "user-defined type not defined"?

Thanks.
This comment was minimized by the moderator on the site
Hi Tom J,
Make sure these three options are checked in the References - VBAProject dialog box.
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/error.png
This comment was minimized by the moderator on the site
This worked perfectly for my first worksheet, but not for the second or third etc (I have up to about 20 worksheets that all need this function). Am I missing something?
This comment was minimized by the moderator on the site
Hi A Owen,
This code only works for one worksheet per time. Sorry for the inconvenience.
This comment was minimized by the moderator on the site
What is the highest nr of worksheets, that can be changed names via Kutools Plus? because the excel letting me only 17 names to changes, and that's it
This comment was minimized by the moderator on the site
I'm using your exact code from the above for VBA code which works perfectly for what I need. However, I have a bunch of macros on a sheet called Job Template that gets copied and reused for every new job. I designed all my macros based on a new copied version called Job Template (2). Once the sheet name is changed to the new job name, the macros no longer work and have to manually do it. I would like to be able to use any of my Macro buttons at any point instead of only using them before I change the sheet name.

Is there a way for the VBA code to always refer to the sheet name before running the rest of the code functions?
This comment was minimized by the moderator on the site
How can I reference two cells. for example name and id number?
This comment was minimized by the moderator on the site
This is exactly what I need, but I need the tab to recreate a date and it isn't working... I assume this is something to do with the way excel works out date and time, can anyone suggest a workaround?
This comment was minimized by the moderator on the site
Hi Nick,
Excel does not support typing the sheet name containing special characters. If the date you type contains the character /, it won't allow you to create the sheet name with that date.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations