Forum Discussion
In VBA how a create a 'log' calculation?
- May 18, 2021
Keep in mind that the Log function in VBA is the natural logarithm (base e = 2.7172...). It corresponds to the worksheet function LN, not to the worksheet function LOG (base 10).
If you need to use the 10-based logarithm, use
... = 1.1665 - 0.07063 * Log(CX + SI + SB) / Log(10)
In VBA, you have to specify multiplication explicitly by using *:
... = 1.1665 - 0.07063 * Log(CX + SI + SB)
- rawlcMay 18, 2021Copper Contributor
Hi, thanks for the advising. In fact it work but the final result get wrong no matter what I do, I tried to specify by parentheses the order of the calcule but still didn't work properly.
- HansVogelaarMay 18, 2021MVP
Keep in mind that the Log function in VBA is the natural logarithm (base e = 2.7172...). It corresponds to the worksheet function LN, not to the worksheet function LOG (base 10).
If you need to use the 10-based logarithm, use
... = 1.1665 - 0.07063 * Log(CX + SI + SB) / Log(10)
- rawlcMay 19, 2021Copper ContributorYes, thank you.