Results 1 to 6 of 6

If Statement in Function code, what is missing?

Threaded View

  1. #1
    Registered User
    Join Date
    04-27-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    If Statement in Function code, what is missing?

    Hi,

    I am new to VBA an trying to write a function that the result wil be a two letter string that shows what type of hours have been worked on an Overtime form. The choices are OT for Overtime, AD for Additional hours or CO for Callout hours.

    I have written the below script but no result is produced am I am at a loss to work out what I have missed. Can anyone please help?

    Function HoursType(OrdinaryHours As Single, ExtraHoursWorked As Single, Callout As String) As String
    Dim totalHours As Single
    totalHours = OrdinaryHours + ExtraHoursWorked
    Dim standardHours As Single
    standardHours = 76
    
    If totalHours > standardHours & Callout = "N" Then
    HoursType = "OT"
    End If
    
    If totalHours > standardHours & Callout = "Y" Then
    HoursType = "CO"
    End If
    
    If totalHours < standardHours Then
    HoursType = "AH"
    
    End If
    End Function
    Last edited by ChicPea; 06-22-2009 at 01:20 AM. Reason: Need to upate subject line to conform withg rules

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1