Consulting

Results 1 to 4 of 4

Thread: problem using a function from an external library in vba

  1. #1

    problem using a function from an external library in vba

    hello!

    I am using an external adding that allows me to check if a given date is a business day according to a calendar. the syntax is: =isbusinessday(date, "calendar")

    where date is the date and calendar can be HK, FR, UK...

    the function returns 1 if it is a business day, 0 otherwise

    right now I have this syntax in a For / Next loop:

    [VBA]
    If isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter1) And _
    isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter2) And _
    isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter3) <> 0 Then
    [/VBA]

    each FinCenter is defined as follows:

    [VBA]
    FinCenter1 = wsHistData.Cells(1, 3)
    FinCenter2 = wsHistData.Cells(2, 3)
    FinCenter3 = wsHistData.Cells(3, 3)
    [/VBA]

    the problem is that it returns an error (like the function is undefined)

    I believe my syntax is wrong. can anyone help please?

    thx

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    You have to check every condition, not only the third one.[VBA]If isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter1) <> 0 And _
    isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter2) <> 0 And _
    isbusinessdays(wsHistData.Cells(2, 6) + i, FinCenter3) <> 0 Then
    MsgBox "All days are different from zero", vbInformation
    Else
    MsgBox "All days are zero", vbInformation
    End If[/VBA]Charlize

  3. #3
    thnks! works much better

    btw: it can happen that FinCenter2 or FinCenter3 = 0 (making the loop crash)
    Could you point me in the right direction in order to ignore the FinCenter when = to 0 please??

  4. #4
    well it seems I have a problem getting the logic of this thing.

    I want to get 1 column with dates
    each date has to be a business day according to at least 1 calendar (max 3 calendars)
    I need to get (end date - start date) iterations

    this is what I have:

    - a start date
    - an end date
    - to 3 calendars
    - 2 functions: isbusinessday and forwarddate

    isbusinessday returns 0 or 1 depending on whether a given date is a business day according to 1 calendar
    forwarddate give the next business day if a given business day is not a trading day

    I have a problem understanding how to loop correctly the thing apparently...

    can someone pont me in the right direction (strategy) in order to find the business days I need accoring to 1 to 3 calendars please??

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •