使用VBA和Excel函数对数不同 [英] Logarithm is different using VBA and Excel function

查看:375
本文介绍了使用VBA和Excel函数对数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在VB中,使用 Log(Range(A2))其中A2是7,我得到 1.94591014905531 ,这是正确的答案。但是,如果在工作表中,我使用 = Log(A2,10) = Log10(a2),I得到 0.84509804 。这里发生了什么?

解决方案

VBA的日志函数是自然日志。如果你想要日志基数十,你将不得不使用对数身份来转换基数。如下所示: Log(x)/ Log(10)


I'm trying to get the log of a number but it looks like the Worksheet function gives one answer, and VBA another.

In VB, using Log(Range("A2")) where A2 is 7, I get 1.94591014905531, which is the correct answer. But, if in the worksheet, I use =Log(A2,10) or =Log10(a2), I get 0.84509804. What's going on here?

解决方案

VBA's Log function is the natural log. If you want log base ten you will have to use the logarithmic identity for converting bases. Like so: Log(x)/Log(10).

这篇关于使用VBA和Excel函数对数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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