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

วิธีการซูมหรือขยายเซลล์ที่เลือกใน Excel 

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

ซูมหรือขยายเซลล์ที่เลือกด้วยรหัส VBA


ซูมหรือขยายเซลล์ที่เลือกด้วยรหัส VBA

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

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

รหัส VBA: ซูมหรือขยายเซลล์ที่เลือก:

Private Sub worksheet_selectionchange(ByVal Target As Range)
'Updateby Extendoffice
    Dim xRg As Range
    Dim xCell As Range
    Dim xShape As Variant
    Set xRg = Target.Areas(1)
    For Each xShape In ActiveSheet.Pictures
        If xShape.Name = "zoom_cells" Then
            xShape.Delete
        End If
    Next
    If Application.WorksheetFunction.CountBlank(xRg) = xRg.Count Then Exit Sub
    Application.ScreenUpdating = False
    xRg.CopyPicture appearance:=xlScreen, Format:=xlPicture
    Application.ActiveSheet.Pictures.Paste.Select
    With Selection
        .Name = "zoom_cells"
        With .ShapeRange
            .ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
            .ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
            With .Fill
                .ForeColor.SchemeColor = 44
                .Visible = msoTrue
                .Solid
                .Transparency = 0
            End With
        End With
    End With
    xRg.Select
    Application.ScreenUpdating = True
    Set xRg = Nothing
End Sub

2. จากนั้นบันทึกและปิดหน้าต่างรหัสนี้ตอนนี้เมื่อคุณเลือกหรือคลิกเซลล์ข้อมูลเซลล์จะขยายเป็นรูปภาพโดยอัตโนมัติดูภาพหน้าจอ:

หมายเหตุ: เซลล์ที่เลือกจะเปลี่ยนกลับเป็นขนาดเดิมหลังจากเลือกเซลล์อื่น

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

🤖 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 (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Ragazzi perso cos' non posso correggere la singola cella...esiste un modo per ingrandire la singola cella una volta selezionata e lavorarci sopra ?
This comment was minimized by the moderator on the site
Hi,
This is great - thank you.

Would it be possible to only have this on a selection of cells on a sheet? For example, all cells in column A, or A3 to A26 for example?
Thank you!
Rhys
This comment was minimized by the moderator on the site
Hi,
I am using Mac-Air and it shows only the color when you click on ac particular cell, pls guide.
This comment was minimized by the moderator on the site
I have the same issue on my MBA M2 running Excel V16.62, blue background but no text seen
This comment was minimized by the moderator on the site
Error 1004 on line 15

Application.ActiveSheet.Pictures.Paste.Select

Why?, what could it be?
This comment was minimized by the moderator on the site
Hi, Mazzi,
The above code works well in my Excel workbook, which Excel version do you use?
This comment was minimized by the moderator on the site
I want to magnify when entering the data
This comment was minimized by the moderator on the site
Hi,
May be, there is no direct way for solving your problem, if you find a good method, please comment here.
This comment was minimized by the moderator on the site
this is cool, but i want it to run in all sheets, how can i do that?
This comment was minimized by the moderator on the site
Hi, Ahmet,
To apply this operation in all worksheets, you can use the below vba code. (You should put the code into the ThisWorkbook module).Please try it.
Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
Dim xRg As Range
Dim xCell As Range
Dim xShape As Variant
Set xRg = Target.Areas(1)
For Each xShape In ActiveSheet.Pictures
If xShape.Name = "zoom_cells" Then
xShape.Delete
End If
Next
If Application.WorksheetFunction.CountBlank(xRg) = xRg.Count Then Exit Sub
Application.ScreenUpdating = False
xRg.CopyPicture appearance:=xlScreen, Format:=xlPicture
Application.ActiveSheet.Pictures.Paste.Select
With Selection
.Name = "zoom_cells"
With .ShapeRange
.ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
With .Fill
.ForeColor.SchemeColor = 44
.Visible = msoTrue
.Solid
.Transparency = 0
End With
End With
End With
xRg.Select
Application.ScreenUpdating = True
Set xRg = Nothing
End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations