Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 6th, 2012, 07:27 PM
cjs cjs is offline
Registered User
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error 424 (object required) when using Application.Caller.Offset


I have written the following code to calculate the difference between two dates, which returns a Error 424 - Object required.

Option Explicit
Public Function DateDifference() As Long
Application.Volatile True
Dim Shift As integer
DateDifference=Datediff("d", Application.Caller.Offset(0,Shift), Application.Caller.Offset(0,Shift+1))
End Function

There are easier ways to do this, but I do need to reference the two cells with the dates in relative to the cell the function is called from. I also need to shift the two date cells along the row, hence the "shift" variable.

Even though it does calculate the difference, it breaks out at the DateDifference line and seems to have an issue with Application.Caller.Offset section. I can get it to work fully by giving it two dates explicitly.

Can someone please help me with the error.

Thanks, CJS.
Old April 9th, 2012, 10:30 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts


If you use this a UDF. You shouldn't get the error.

If you are calling from some other sub/function. It might throw the error

C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime 424 object required - unconverted database panda2 Access VBA 0 November 4th, 2010 05:23 PM
Run Time Error 424 "Object Required" paul31berks Access VBA 8 October 31st, 2010 04:49 PM
runtime error 424: object required anjana BOOK: Excel 2003 VBA Programmer's Reference 0 July 13th, 2009 12:44 PM
VBA Object required - RTE 424 dbrother Access VBA 2 November 2nd, 2007 04:06 PM
Runtime Error 424: Object needed tobian Excel VBA 4 February 20th, 2006 10:41 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.