获取单元格的值,或者如果是公式 - vba,则更改该值 [英] get value of a cell, or change the value if it's formula - vba

查看:385
本文介绍了获取单元格的值,或者如果是公式 - vba,则更改该值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在迭代我的工作表中的单元格,并得到这样的单元格的vallue:

I am iterating through cells in my worksheet, and getting the vallue of the cell like so:

item = Cells(i, 3).value

/ p>

though, sometimes, I have some formulas in the cells, like:

=BD=F5=E3
=some string

它是类型错误,但excel生成它作为公式,所以当我对这些单元格这样做: Cells()。Value 我得到类型不匹配错误。

it is type mistakes, but excel generates it as formulas, so when I do on those cells this: Cells().Value I get type mismatch error.

有没有办法传递这个错误?或者像是将工作表中的所有单元格声明为字符串,无论什么?

is there a way to pass this error? or something like declaring all cells in the worksheet as strings no matter what?

谢谢

推荐答案


  • 单元格(r,c).Value 给出单元格的显示值

  • 单元格(r,c).Text 给出返回的字符串的显示值

  • 单元格r,c).Formula 返回单元格的公式

  • 单元格(r,c).FormulaR1C1 返回R1C1语法中的公式。

    • Cells(r, c).Value gives the displayed value of the cell
    • Cells(r, c).Text gives the displayed value returned as a string
    • Cells(r, c).Formula returns the formula of the cell
    • Cells(r, c).FormulaR1C1 returns the formula in R1C1 syntax.
    • 这篇关于获取单元格的值,或者如果是公式 - vba,则更改该值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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