May 18 2021 10:37 AM
Hi, so I want to create a function in excel VBA that is it: '= 1.16650 - 0.07063 log (CX + SI+ SB)'
But I don't know how to make 'log' work, because I can't simply digit 'log', it will not allow, it will say 'it was expected: end of instruction'
Sorry about my English, not my first language.
May 18 2021 10:52 AM
In VBA, you have to specify multiplication explicitly by using *:
... = 1.1665 - 0.07063 * Log(CX + SI + SB)
May 18 2021 12:00 PM
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.
May 18 2021 12:22 PM - edited May 19 2021 12:47 AM
SolutionKeep 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)
May 18 2021 12:22 PM - edited May 19 2021 12:47 AM
SolutionKeep 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)