log and round

hill0093

Board Regular
Joined
Dec 4, 2011
Messages
163
I am just trying to learn about round() and log().
Compiler doesn't like the log line.
What would be correct?
Code:
Function funcNam(funcArg As Double) As String
  Dim logArg As Double
  Dim rndLogArg As Double
  logArg = Log10{funcArg)
  rndLogArg = Round(logArg, 0)
  Sheets("WrkShtNam").Cells(7, 9).Value = funcArg     'for debug
  Sheets("WrkShtNam").Cells(8, 9).Value = logArg      'for debug
  Sheets("WrkShtNam").Cells(9, 9).Value = rndLogArg   'for debug
  funcNam = rndLogArg
End Function
Also if I changed this function to a Sub, how do I call it?
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
logArg=application.Log10(funcArg)
or
logArg=worksheetfunction.Log10(funcArg)
or
logArg=application.worksheetfunction.Log10(funcArg)
 

hill0093

Board Regular
Joined
Dec 4, 2011
Messages
163
The compiler calls the left parenthesis an invalid character in each line.
Code:
logArg=Log10(funcArg)
logArg=application.Log10(funcArg)
logArg=worksheetfunction.Log10(funcArg)
logArg=application.worksheetfunction.Log10(funcArg)
 

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
The first line causes complaint as expected, but the other three compile fine here.
What version of excel are you using?
 

hill0093

Board Regular
Joined
Dec 4, 2011
Messages
163
Thanks for responding. I use Excel 2003.
 

p45cal

Well-known Member
Joined
Nov 10, 2009
Messages
4,763
I tested this on Excel 2003 and 2010 - no compile errors.
Have you tried just running the code?
 

hill0093

Board Regular
Joined
Dec 4, 2011
Messages
163
Ya, I discovered my error, but I'm too embarrassed to
tell you that it was a curly bracket that I didn't
notice even if it was pointed out to me.
Thanks for your help.
 

Forum statistics

Threads
1,171,630
Messages
5,876,545
Members
433,199
Latest member
guerin47

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top