Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Offset in Custom Function Problem 1

Status
Not open for further replies.

bigz60

Technical User
Apr 18, 2007
40
US
Hello. I am trying to create a custom function that uses the offset function. I am creating this to eliminate some of the input parameters, which will allow the end users to only have to input two parameters (the rows and cols params).

Here is my function:
Code:
Public Function roff(x As Integer, y As Integer)


roff = WorksheetFunction.Offset(January, x, y, 1, 1)

End Function

January is a named range in the worksheet.

When I try to enter the roff function with the two params, i get the dreaded #VALUE.

I am not sure where to go from there.
 
The top inconsistency is that Offset is NOT in the list of WorksheetFunctions available from Vba (check the help on line).

Try this:
Code:
Public Function roff(x As Integer, y As Integer)
roff = Range("January").Range("A1").Offset(x, y).Value
End Function

Bye.


Anthony047 (GMT+1)
 
Thank you Anthony. That works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top