How to avoid error 2015 when using ActiveCell.Offsett in own function

  • Thread starter Thread starter Torben Laursen
  • Start date Start date
T

Torben Laursen

Hi
I have this simple test function that I'm using in order to learn how to use
Offset:
Code:
Option Explicit
Option Base 1
Public Function PT_Flash(P As Double, T As Double) As Double
Dim PT_Value As Double
ActiveCell.Offset(10, 10).Value = "test me"
'the line above gives a error.
PT_Value = P * T
PT_Flash = PT_Value
End Function

But no matter what I have tryed I cannot get the line with
"ActiveCell.Offset" to work, is allways give me error 2015
Any hint to as how to use ActiveCell.Offset?

Thanks Torben
 
Are you calling this function from a worksheet cell? If so, it
won't work. A function called from a worksheet cell cannot change
the Excel environment in any way, including changing the values
of other cells.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Hi Chip

Yes I am.
But if can not do that how can I return a number of values from the function
call to the sheet?

What I want is for the user to call a function in a number of cells in a
columen and then return a range of information in each row next to the cell
that is calling the function

Thanks Torben
 
Back
Top