Passing Date to UDF causing Catastrophic Failure Automation Error

pizzaboy

Board Regular
Joined
Mar 23, 2015
Messages
56
Office Version
  1. 2019
Platform
  1. Windows
I have a couple of dates I am passing to a user defined function. One date is causing the error whilst the vba is fine with the other...

The error only occurs when Excel is started up. When I stop the code running and run the function again, its fine!?


The date which VBA is fine with:
Code:
'These values are set in the Formulas "Name Manager"
'SETTING_SEARCH_RELEASED_MONTHS_LATEST =3
'SETTING_SEARCH_NEXTMONTH_STARTDAY =14

'[LAST UPDATE] = 27/06/2019


[TO]=IF([LAST UPDATE]<>"",DATE(YEAR([LAST UPDATE]),MONTH([LAST UPDATE])-SETTING_SEARCH_RELEASED_MONTHS_LATEST+IF(DAY([LAST UPDATE])>=SETTING_SEARCH_NEXTMONTH_STARTDAY,1,0),1)-1,"")


The date VBA doesn't like:
Code:
[MOST RECENT]=DATE(YEAR(NOW()),MONTH(NOW())-SETTING_IMDB_SEARCH_RELEASED_MONTHS_LATEST+IF(DAY(NOW())>=SETTING_IMDB_SEARCH_NEXTMONTH_STARTDAY,1,0),1)-1


Both dates look fine (visually on the spreadsheet).


Simply defining the UDF is causing the error, regardless of whether I use the dates or not:
Code:
=GetLink([TO],[MOST RECENT],[RATING],[VOTES])

    Public Function GetLink(pDateTo As Date, pDateRecent As Date, pRating As String, pVotes As String, Optional pLanguages As String = "", Optional ByVal pNoOfRecords As Integer = 250) As String
        'pDateFrom As Date,
        Dim result As String
        


        
        GetLink = result
    End Function


As I said, this only happens on Excel startup. It runs fine once the I force the code to stop running and call the function again...


Any help would be greatly appreciated.

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top