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

วิธีแปลงสตริงข้อความเป็นสูตรใน Excel

หากมีสตริงข้อความจำนวนมากในรูปแบบ = A1 + B1 ซึ่งคุณต้องแปลงสตริงข้อความเหล่านี้เป็นสูตรจริงและคำนวณค่าในแผ่นงานของคุณน่าเสียดายที่ไม่มีวิธีโดยตรงในการแก้ปัญหาใน Excel แต่ที่นี่ฉันสามารถพูดคุยเกี่ยวกับเทคนิคที่น่าสนใจสำหรับคุณ

แปลงสตริงข้อความเป็นสูตรด้วย User Defined Function

แปลงสตริงข้อความเป็นสูตรด้วย Kutools for Excel


ลูกศรสีฟ้าฟองขวา แปลงสตริงข้อความเป็นสูตรด้วย User Defined Function

รหัส VBA สั้น ๆ ต่อไปนี้สามารถช่วยคุณจัดการกับปัญหาที่แปลงข้อความเป็นสูตรตามขั้นตอนเหล่านี้:

1. กด ALT + F11 และจะเปิดไฟล์ หน้าต่าง Microsoft Visual Basic for Applications.

2. คลิก สิ่งที่ใส่เข้าไป > โมดูลและวางรหัสต่อไปนี้ในไฟล์ หน้าต่างโมดูล.

รหัส VBA: แปลงสตริงข้อความเป็นสูตร

Function Eval(Ref As String)
Application.Volatile
Eval = Evaluate(Ref)
End Function

3. บันทึกรหัสนี้และกลับไปที่แผ่นงานของคุณป้อนสูตรนี้ = ประเมิน (C1) ลงในเซลล์ว่าง (C1 มีเซลล์สตริงข้อความที่คุณต้องการแปลงเป็นสูตร) ​​ดูภาพหน้าจอ:

doc-convert-text - เป็น-formula1

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

doc-convert-text - เป็น-formula1


ลูกศรสีฟ้าฟองขวา แปลงสตริงข้อความเป็นสูตรด้วย Kutools for Excel

หากคุณไม่ชอบใช้รหัสด้านบนคุณสามารถสมัครได้ Kutools สำหรับ Excel's แปลงข้อความเป็นสูตร ด้วยความช่วยเหลือคุณยังสามารถแปลงสตริงข้อความเป็นสูตรได้ในครั้งเดียว

Kutools สำหรับ Excel มีเครื่องมือ Excel ที่มีประโยชน์มากกว่า 300 รายการ ทดลองใช้ฟรีโดยไม่มีข้อ จำกัด ใน 30 วัน Get it Now.

หลังจากติดตั้ง Kutools for Excel แล้วโปรดดำเนินการดังนี้:

1. เลือกสตริงข้อความที่คุณต้องการแปลง

2. คลิก Kutools > ตัวแปลงเนื้อหา > แปลงข้อความเป็นสูตรดูภาพหน้าจอ:

doc-convert-text - เป็น-formula1

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

doc-convert-text - เป็น-formula4 -2 doc-convert-text - เป็น-formula5

หากต้องการทราบข้อมูลเพิ่มเติมเกี่ยวกับคุณลักษณะการแปลงข้อความเป็นสูตร


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

วิธีแปลงสูตรเป็นสตริงข้อความใน 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 (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am finding this to be not working properly. As everyone else has said (and I could not see a satisfactory solution), it does not work when trying to pull in stuff from other worksheets in the same workbook. It's frustrating and I am having to give up on this and find another solution. So the Google search continues!
This comment was minimized by the moderator on the site
Thank you very much!!! GREAT IDEA!!!
This comment was minimized by the moderator on the site
Hello
For the first defined function way, I have a problem.
when the resources for concatenate function are in another worksheet, Eval function works properly when that resource worksheet is open, But immediately when I close that resource worksheet, Eval function Not working. How I can change the codes for eval function to use closed resource worksheets?
This comment was minimized by the moderator on the site
Hello Johnny
about Hussein’s issue, if the external workbook is closed INDIRECT gives #REF! error. Do you have other solution?
This comment was minimized by the moderator on the site
use indirect only works with open workbooks.


solution is to use indirect.ext from morefunc.


regards,
Hasan nasralla
This comment was minimized by the moderator on the site
Hi Hussein,

Just use the INDIRECT function in Excel. Does the same thing.
This comment was minimized by the moderator on the site
Greetings, the above code works perfectly inside the same workbook across different sheets, but in case i have a cell reference to an external workbook it returns #VALUE!. the formulas were calculating normally earlier.
Example for the formula can't be evaluated correctly: IFERROR(INDEX('[Tracking-OSP Outside Riyadh-07-09-2017.xlsx]Tracking WO'!$U$3:$U$19000,MATCH(A3&"",'[Tracking-OSP Outside Riyadh-07-09-2017.xlsx]Tracking WO'!$B$3:$B$19000,0)),INDEX('[Tracking-OSP Outside Riyadh-07-09-2017.xlsx]Tracking WO'!$U$3:$U$19000,MATCH(value(A3),'[Tracking-OSP Outside Riyadh-07-09-2017.xlsx]Tracking WO'!$B$3:$B$19000,0))).
This comment was minimized by the moderator on the site
The replace = with = works, so relieved. Thank you to whoever discovered and shared this nugget of Excel gold.
This comment was minimized by the moderator on the site
To clarify my other comment, I mass replaced the "=" character with the same "=" character, and that made the strings turn into formulas.
This comment was minimized by the moderator on the site
Hi Rich,
I'm just reading you comment on turning text into a formula. It seems that the function as mentioned above is not working. I'm not really a programmer but what i did is converting a formula into a text and in the text i have to replace a few values and combine it again in one text but now i need to convert it back into a formula. Could you give me a tip.
Regards
Frans
This comment was minimized by the moderator on the site
I don't know if this would always work, but I had a number of cells that had formulas stored as text strings. I did a full worksheet find replace on the "=" character, and all of my strings converted to formulas with that one action.
This comment was minimized by the moderator on the site
Thank you. Works well with the user defined function... I could do what I could not using the default functions of INDIRECT, ADDRESS et al provided. It fell short when I had a range to be input.
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