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

วิธีซ่อนสูตร แต่แสดงผลลัพธ์โดยไม่ปกป้องแผ่นงานใน Excel

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

ซ่อนสูตร แต่แสดงผลลัพธ์โดยไม่ปกป้องแผ่นงานด้วยรหัส VBA


ซ่อนสูตร แต่แสดงผลลัพธ์โดยไม่ปกป้องแผ่นงานด้วยรหัส VBA

หากต้องการซ่อนสูตร แต่แสดงผลลัพธ์โดยไม่ปกป้องแผ่นงานโปรดทำดังนี้

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

2 ใน Microsoft Visual Basic สำหรับแอปพลิเคชัน โปรดคัดลอกและวางรหัส VBA ลงในหน้าต่างรหัส

รหัส VBA: ซ่อนสูตร แต่แสดงผลลัพธ์โดยไม่ปกป้องแผ่นงาน

Dim xDic As New Dictionary
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim xCell As Range
    Dim xRg As Range
    Set xRg = Range("C1:C10")
    If xDic.Count <> xRg.Count Then
        For Each xCell In xRg
            xDic.Add xCell.Address, xCell.FormulaR1C1
        Next
    End If
    If (Target.Count = 1) And (Not Application.Intersect(xRg, Target) Is Nothing) And (Target.HasFormula) Then
        With Target
            .Value = .Value
        End With
    Else
        For Each xCell In xRg
            xCell.Formula = xDic.Item(xCell.Address)
        Next
    End If
End Sub

หมายเหตุ: ในโค้ด C1: C10 คือช่วงเซลล์ที่คุณต้องการซ่อนสูตรไว้ภายใน โปรดเปลี่ยนตามความต้องการของคุณ

3 จากนั้นคลิก เครื่องมือ > เอกสารอ้างอิง…. ตรวจสอบ รันไทม์ Microsoft Script แล้วคลิกไฟล์ OK ปุ่มใน เอกสารอ้างอิง - VBAProject หน้าต่าง. ดูภาพหน้าจอ:

4 กด อื่น ๆ + Q ปุ่มเพื่อปิดไฟล์ Microsoft Visual Basic สำหรับแอปพลิเคชัน หน้าต่าง

จากนี้ไปเมื่อคุณคลิกที่เซลล์ในช่วงที่ระบุสูตรจะถูกซ่อนทันทีในแถบสูตร


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

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

🤖 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 (20)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
saya da coba sesuai coding nya, bisa berjalan, tetapi di layar ketika saya klik ke tempat yang dimaksud ada keluar tanda loading, (tanda bulat berkedip). File saya mmg 18 MB, bagaimana caranya agar tidak keluar tanda kedip tersebut ?
This comment was minimized by the moderator on the site
Hi akkia,
The problem you mentioned is not reproduced in my case. May I ask which Excel version you are using?
This comment was minimized by the moderator on the site
dia tetap loading ya ko ?
This comment was minimized by the moderator on the site
Thank you for this code, I really needed something like this
Rated 5 out of 5
This comment was minimized by the moderator on the site
formula worked but the problem is when we close the sheet and reopen it than VBA not worked...
This comment was minimized by the moderator on the site
Hi, To continue using this VBA in future, after adding the code, please save the workbook as an Excel Macro-Enabled Workbook.Click File > Save As. In the Save As dialog box, select Excel Macro-Enabled Workbook from the Save as type drop down list, then click the Save button.And then use this excel macro-enabled workbook in the future.
This comment was minimized by the moderator on the site
Hi Im gracy, i am trying to hide the formula in a particular column without password protecting the sheet. i copy pasted the entire code and changed the cells but still unable to hide the formula. Can you please assist.

This comment was minimized by the moderator on the site
Thank you. Formula Worked.
This comment was minimized by the moderator on the site
after this vba code apply new sum formula result not showing in cell, please help....
This comment was minimized by the moderator on the site
If we press and hold the mouse left click to a cell, the formula shows until you release the left click. Otherwise this should work fine.
This comment was minimized by the moderator on the site
I tried using the VBA code but after applying this code my excel is getting slow and hanged.please help me in resolving this issue.
This comment was minimized by the moderator on the site
There is easy way as well.
Select the cell or cells you want to hide the formula or data.
Go to Home --> Format --> Format Cells --> Number --> Custom
Under Type, Remove General and Enter """"
The cell value or formula do not appear on the screen
However it will appear in the Formula bar if you select the cell.
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