提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何将文本字符串转换为Excel中的公式?

如果有很多文本字符串为= A1 + B1格式,您需要将这些文本字符串转换为实数公式并在工作表中计算它们的值,不幸的是,没有直接的方法可以在Excel中解决它。 但是,在这里我可以为你讨论一些有趣的技巧。

使用用户定义的函数将文本字符串转换为公式

使用Kutools for Excel将文本字符串转换为公式

Office选项卡在Office中启用选项卡式编辑和浏览,使您的工作更轻松......
Kutools for Excel - 最佳办公生产力工具将解决您的大部分Excel问题
  • 重用任何东西: 将最常用或最复杂的公式,图表和其他任何内容添加到您的收藏夹中,并在将来快速重复使用它们。
  • 超过20文本功能: 从文本字符串中提取数字; 提取或删除部分文本; 将数字和货币转换为英语单词...
  • 合并工具:多个工作簿和表格合二为一; 合并多个单元格/行/列而不丢失数据; 合并重复行和总和...
  • 拆分工具:根据价值将数据拆分为多个表格; 一个工作簿到多个Excel,PDF或CSV文件; 一列到多列......
  • 粘贴跳过 隐藏/过滤行; 数和总和 按背景颜色; 创建邮件列表和 通过Cell的价值发送电子邮件...
  • 超级过滤器: 创建高级过滤方案并应用于任何工作表; 排序 按周,日,频率等; 筛选 通过大胆,公式,评论......
  • 超过300强大的功能; 适用于Office 2007-2019和365; 支持所有语言; 在公司轻松部署; 全功能60天免费试用。

箭头蓝色右泡 使用用户定义的函数将文本字符串转换为公式


以下简短的VBA代码可以帮助您处理将文本转换为公式的问题,如下所示:

1。 按住 ALT + F11 键,然后打开 Microsoft Visual Basic for Applications窗口.

2。 点击 插页 > 模块,并将以下代码粘贴到 模块窗口.

VBA代码:将文本字符串转换为公式

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

3。 保存此代码并返回到您的工作表,输入此公式 =的eval(C1) 进入空白单元格(C1 包含要转换为公式的文本字符串单元格),请参阅截图:

DOC-转换文本 - 到formula1

4。 然后按 输入 键,然后选择单元格D1,将填充句柄拖到要应用此公式的范围。 看截图:

DOC-转换文本 - 到formula1


箭头蓝色右泡 使用Kutools for Excel将文本字符串转换为公式

如果你不喜欢使用上面的代码,你可以申请 Kutools for Excel将文本转换为公式 功能,在它的帮助下,您还可以将文本字符串一次转换为公式。

Kutools for Excel 包含了比300更方便的Excel工具。 免费试用30天无限制。 立即获取.

在安装Kutools for Excel后,请按照以下步骤操作:

1。 选择您想要转换的文本字符串。

2。 点击 Kutools > 内容转换器 > 将文本转换为公式,看截图:

DOC-转换文本 - 到formula1

3。 所有选中的文本字符串都已转换为实数公式并获取它们的值。 查看屏幕截图:

DOC-转换文本 - 到formula4 -2 DOC-转换文本 - 到formula5

了解更多关于此转换文本到公式功能。


相关文章:

如何将公式转换为Excel中的文本字符串?


Kutools for Excel - 最佳办公生产力工具提高80%的生产力

  • 重用: 快速插入 复杂的公式,图表 以及你以前用过的任何东西; 加密单元格 密码; 创建邮件列表 并发送电子邮件...
  • 超级方程式酒吧 (轻松编辑多行文字和公式); 阅读布局 (轻松读取和编辑大量单元格); 粘贴到过滤范围...
  • 合并单元格/行/列 不丢失数据; 分裂细胞含量; 组合重复的行/列...防止重复的细胞; 比较范围...
  • 选择复制或唯一 行; 选择空行 (所有细胞都是空的); 超级查找和模糊查找 在许多工作簿中; 随机选择......
  • 精确复制 多个单元格而不更改公式参考; 自动创建参考 多张表; 插入项目符号,复选框等等......
  • 提取文本,添加文本,按位置删除, 删除空间; 创建和打印分页小计; 在单元格内容和注释之间转换...
  • 超级过滤器 (将过滤方案保存并应用到其他工作表); 高级排序 按月/周/日,频率等; 特殊过滤器 用粗体,斜体......
  • 结合工作簿和工作表; 根据键列合并表; 将数据拆分为多个表格; 批量转换xls,xlsx和PDF...
  • 超过300强大的功能。 支持Office / Excel 2007-2019和365。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
kte tab 201905

Office选项卡为Office提供选项卡式界面,使您的工作更轻松

  • 在Word,Excel,PowerPoint中启用选项卡式编辑和阅读,Publisher,Access,Visio和Project。
  • 在同一窗口的新选项卡中打开并创建多个文档,而不是在新窗口中。
  • 通过50%提高您的工作效率,每天为您减少数百次鼠标点击!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    willyfred · 1 years ago
    Hello Johnny
    about Hussein’s issue, if the external workbook is closed INDIRECT gives #REF! error. Do you have other solution?
    • To post as a guest, your comment is unpublished.
      Hasan nasralla · 1 years ago
      use indirect only works with open workbooks.


      solution is to use indirect.ext from morefunc.


      regards,
      Hasan nasralla
  • To post as a guest, your comment is unpublished.
    Johnny · 1 years ago
    Hi Hussein,

    Just use the INDIRECT function in Excel. Does the same thing.
  • To post as a guest, your comment is unpublished.
    Hussein · 2 years ago
    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))).
  • To post as a guest, your comment is unpublished.
    Tamarind · 2 years ago
    The replace = with = works, so relieved. Thank you to whoever discovered and shared this nugget of Excel gold.
  • To post as a guest, your comment is unpublished.
    Rich · 2 years ago
    To clarify my other comment, I mass replaced the "=" character with the same "=" character, and that made the strings turn into formulas.
    • To post as a guest, your comment is unpublished.
      Frans · 1 months ago
      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
  • To post as a guest, your comment is unpublished.
    Rich · 2 years ago
    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.
  • To post as a guest, your comment is unpublished.
    Srini · 3 years ago
    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.
  • To post as a guest, your comment is unpublished.
    Craig Nichol · 3 years ago
    Hi your macro works, though im using it to extract a value from another worksheet that I specify in the workbook. Problem is that i'd like it read this value even when this external workbook is closed, however if it is closes eval returns a REF error. Is there a way that eval can be modified to open/display values of files that are not open?

    Thanks:)
    • To post as a guest, your comment is unpublished.
      Didson · 2 years ago
      In order to have values always available extracted from other workbooks even when they are closed, you should implement some power query. I faced this problem a while ago, and it is working perfectly for me now.
      The problem I am having now though is that I want to update several formulas in "daughter" workbooks, by referencing the source in my "mother" workbook, and through power query I managed to get to the point to have all formulas updated in string format in the daughters sheets, however, even by using the Evaluate function, it seems to not work with lists, conditional formating, nor more complex formulas which use many functions or matrix referencing... :(
      I am reeeeally having a hard time trying to find a way to make this work out now from here on forward...
  • To post as a guest, your comment is unpublished.
    Thomas Tanner · 3 years ago
    I applied the macro as described, but I receive "#VALUE" as an output. Any ideas what could've gone wrong?

    Help would be highly appreciated! Thank you.
  • To post as a guest, your comment is unpublished.
    Huseyin · 4 years ago
    i have a question how can i make this text as formula?