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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
logArg=application.Log10(funcArg)
or
logArg=worksheetfunction.Log10(funcArg)
or
logArg=application.worksheetfunction.Log10(funcArg)
 
Upvote 0
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)
 
Upvote 0
The first line causes complaint as expected, but the other three compile fine here.
What version of excel are you using?
 
Upvote 0
I tested this on Excel 2003 and 2010 - no compile errors.
Have you tried just running the code?
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,551
Messages
6,114,267
Members
448,558
Latest member
aivin

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
Back
Top