T
Tony
Hello - I'm trying to write a simple VBA function to calc Income Tax given a
value for income. I have several worksheets in my workbook. From sheet 1 I
want to set a value in the Income_Tax sheet, have it do the calc, then
return the results. Here's what I got:
Function IncomeTax(Income As Double) As Double
ActiveWorkbook.Sheets("Income_Tax").Range("A1").Value = Income
ActiveWorkbook.Sheets("Income_Tax").Range("B1").Calculate
IncomeTax = ActiveWorkbook.Sheets("Income_Tax").Range("B1").Value
End Function
But when I try to use that function in sheet 1, I get a #Value! error.
What's wrong with this code?
Thanks for your help.
value for income. I have several worksheets in my workbook. From sheet 1 I
want to set a value in the Income_Tax sheet, have it do the calc, then
return the results. Here's what I got:
Function IncomeTax(Income As Double) As Double
ActiveWorkbook.Sheets("Income_Tax").Range("A1").Value = Income
ActiveWorkbook.Sheets("Income_Tax").Range("B1").Calculate
IncomeTax = ActiveWorkbook.Sheets("Income_Tax").Range("B1").Value
End Function
But when I try to use that function in sheet 1, I get a #Value! error.
What's wrong with this code?
Thanks for your help.