Consulting

Results 1 to 3 of 3

Thread: Get Tenor - Bucket Function

  1. #1

    Question Get Tenor - Bucket Function

    Hi,

    I have the below function which buckets tenor points depending on the number of days returned but i cannot return the value of the "bucket" back to excel in the formula.

    the formula in Excel is = GetTenor("a2") and this should return, for example, "1M" but returns an error. I have attached the spreadsheet and code.

    Thanks

    Sarah


    Public bucket As String
    
    Public Function GetTenor(bucket As String, x As Integer)
    If x < 1 Then
        bucket = "ON"
    End If
    If x = 1 Then
        bucket = "1D"
    End If
    If x > 1 And x <= 7 Then
        bucket = "1W"
    End If
    If x > 7 And x <= 30 Then
        bucket = "1M"
    End If
    If x > 30 Then
        bucket = "OVER"
    End If
    End Function

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Public Function GetTenor(x As Integer)
    
        If x < 1 Then
            GetTenor = "ON"
        ElseIf x = 1 Then
            GetTenor = "1D"
        ElseIf x <= 7 Then
            GetTenor = "1W"
        ElseIf x <= 30 Then
            GetTenor = "1M"
        ElseIf x > 30 Then
            GetTenor = "OVER"
        End If
    End Function
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thank you so much - I can be such a plank of wood sometimes - should have seen that!!

    thanks for all your help,

    Have a nice day

    Sarah

Posting Permissions

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