Calling Formula

Hi,

Im using a macro button to call the below formula

When i press the button it returns a ref error, if i click it again, it returns the correct formula, how is this possible?

If i step through on the editor, it temporarily returns ref but nealry instantly reurns formula, im confused!

Sub Check_Date()


Range("C13").Formula = "=IF(OR(INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[NA.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Europe.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[MENA.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Asia.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[LATAM.xlsm]PB Review'!$H$1)=B13),""Yes"",""No"")"

    Range("C13").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False

End Sub

Open in new window

Seamus2626Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
Please try this condensed version.
Sub Check_Date()


    Range("C13").Value = Application.Evaluate("=IF(OR(INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[NA.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Europe.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[MENA.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Asia.xlsm]PB Review'!$H$1)=B13,INT('http://teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[LATAM.xlsm]PB Review'!$H$1)=B13),""Yes"",""No"")")

End Sub

Open in new window

Seamus2626Author Commented:
Hey man, that returned a value error
aikimarkCommented:
@Seamus

I have no way to evaluate the formula, since it references a non-accessible URL location.  What can
you tell me about it?  Most of the time, I would have expected UNC file references like this:
Sub Check_Date()

    Range("C13").Value = Application.Evaluate("=IF(OR(INT('\\teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[NA.xlsm]PB Review'!$H$1)=B13,INT('\\teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Europe.xlsm]PB Review'!$H$1)=B13,INT('\\teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[MENA.xlsm]PB Review'!$H$1)=B13,INT('\\teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[Asia.xlsm]PB Review'!$H$1)=B13,INT('\\teams.global.hsbc/gtb/Global-SPM/client-comms/PB-PM/Shared Documents/Expiring Content - Maintenance Reports/[LATAM.xlsm]PB Review'!$H$1)=B13),""Yes"",""No"")")

End Sub

Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Seamus2626Author Commented:
@aikimark

The formula is referencing sharepoint sites - i am very confused to why it returns the correct result when i run the sub twice (i.e. ckick the button twice)

So there is a cell on the current worksheet with todays date - the formula checks the date stamp on the files in sharepoint to see if they match

Thanks
aikimarkCommented:
Unfortunately, I don't have Sharepoint in my environment to try and recreate your problem. :-(

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Seamus2626Author Commented:
All good aikimark, sorted now, thanks!
aikimarkCommented:
@Seamus

What was the solution?  My comment does not appear to be a fix for the problem.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.