title: Excel VBA correct date type for numbers?
body: <p>I have a template that records hours worked by employees. Column 5 shows their contracted hours for the week and Column 14 shows additional hours they work. Part time staff (less than 37.5 hrs p/week) who work additional hours are paid a standard rate. However once they exceed 37.50 hours for the week they are paid at time and a half (this is recorded in a seperate column).</p>
  
  <p>The code below picks up the total number of hours for the week (column 18) and if it exceeds 37.5 it will prompt the user to record some of the hours at time and a half. It's a failsafe way of ensuring people are paid correctly. </p>
  
  <p>The code below works almost perfectly however if the contracted hours are less than 10, the message box pops up regardless. I think it is because I have a String data type for the hours in the code is as a String but I can't seem to get it to work with other data types. Any assistance would be much appreciated. </p>
  
  <pre><code>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  
  If Target.Column = 14 Then
  
  Dim I As Integer, CheckHours As Boolean
  Dim MonthX As Worksheet
  I = 6
  CheckHours = False
  Set MonthX = ThisWorkbook.ActiveSheet
  
  Dim FT As String
  FT = 37.5
  
  Application.ScreenUpdating = False
  
  'Use the Employee Number column to perform the check
  Do While MonthX.Cells(I, 3) &lt;&gt; ""
  
      'Declare variables
          Dim ContractHours As String
          Dim HoursPaid As String
          Dim TotalHours As String
  
          ContractHours = MonthX.Cells(I, 5)     
          HoursPaid = MonthX.Cells(I, 14)
          TotalHours= MonthX.Cells(I, 18)
  
              'If the contract hours plus the additional hours are greater than 37.50 then display warning
              If TotalHours &gt; FT Then
                  MsgBox "WARNING: Check the additional hours entered for " &amp; _
                  MonthX.Cells(I, 2).Value &amp; " " &amp; MonthX.Cells(I, 1).Value &amp; _
                  " as they will need to be split between Additional Basic and Overtime." &amp; _
                  vbNewLine &amp; vbNewLine &amp; _
                  "Please refer to the Additional Hours Guidelines tab for more information.", vbOKOnly, "Please Check"
  
                  CheckHours = True
  
              End If
  
      I = I + 1
  Loop
  
  'Cancel boolean
  If CheckHours = True Then
      Cancel = True
      End If
  
  Application.ScreenUpdating = True
  
  End If
  
  End Sub
  </code></pre>