宏将公式更改为满足条件的选定单元格的值 [英] Macro to change formulas to values for selected cells meeting conditions

查看:61
本文介绍了宏将公式更改为满足条件的选定单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在工作簿中进行搜索,并将包含公式中某些文本的所有单元格替换为单元格值,同时将剩余单元格保留为公式

解决方案

rjades,

re:更改工作表公式



使用类似下面的内容...

'---

  Sub FormulasToValues()

  Dim strFormula As String

  Dim rCell As Excel.Range

 

  Application.Calculation = xlCalculationManual

 对于每个rCell在Excel.Selection.Cells

   strFormula = rCell.Formula

  如果InStr(1,strFormula,"Road",vbBinaryCompare)> 1然后rCell.Value = rCell.Value

 下一个

  Application.Calculation = xlCalculationAutomatic

End Sub

'--- $
Jim Cone

美国俄勒冈州波特兰市$ b https://goo.gl/IUQUN2  (Dropbox)

I want to do a search in a workbook and replace all cells containing certain text in the formulas with the cells values while leaving the remaining cells as formulas

解决方案

rjades,
re: change worksheet formulas

Use something similar to the following...
'---
 Sub FormulasToValues()
 Dim strFormula As String
 Dim rCell As Excel.Range
 
 Application.Calculation = xlCalculationManual
 For Each rCell In Excel.Selection.Cells
   strFormula = rCell.Formula
   If InStr(1, strFormula, "Road", vbBinaryCompare) > 1 Then rCell.Value = rCell.Value
 Next
 Application.Calculation = xlCalculationAutomatic
End Sub

'---
Jim Cone
Portland, Oregon USA
https://goo.gl/IUQUN2 (Dropbox)


这篇关于宏将公式更改为满足条件的选定单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆