ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Custom Function??? (https://www.excelbanter.com/excel-programming/395663-re-simple-custom-function.html)

Mike

Simple Custom Function???
 
Thank you!

"Jim Thomlinson" wrote:

Public Function MyFunc(ByVal RowNum As Long, _
ByVal ColumnNum As Long) As Variant
MyFunc = Cells(RowNum, ColumnNum).Value
End Function

--
HTH...

Jim Thomlinson


"Mike" wrote:

I'm trying to create a simple custom function. I'm trying to have the user
input the row and column numbers in the function (like =MYFUN(1,2)
referencing cell B1) and have it return the contents of that cell. So I
thought I would use the following.

Function MYFUN(varA, varB)
MYFUN = WorksheetFunction.Indirect(Address(varA, varB))
End Function

So then I tried simplifying it with just
MYFUN = WorksheetFunction.Address(varA, varB)
thinking it would return $B$1 but nothing.

What am I doing wrong?



All times are GMT +1. The time now is 01:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com