Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue calling VBA Function from within another Function
    primarykey
    data
    text
    <p>Below is the code I've written however I keep getting an issue with the line I've added the comment to, and only that line. I've commented out all the other lines and isolated this as the problem line but for the life of me and with the hour or more of research I've done I cannot figure out what the issue is. It's probably a really obvious one, but I'm really stuck and it's driving me crazy.</p> <p>Anyway, the code is to be used to take a Range of data containing shift times and language capability and show how many people with a specific language are available during a given time period (The_Time in the code below)</p> <p>Any help would be greatly appreciated!</p> <pre><code>Function ReturnAvailability(The_Time As String, The_Info As Range) Dim The_Lang As String Dim The_Shift_Start As String Dim The_Shift_End As String Dim stGotIt As String Dim stCell As Integer Dim Counter As Integer Counter = 0 For Each r In The_Info.Rows For Each c In r.Cells stCell = c.Value If InStr(stCell, "Eng") &gt; 0 Then The_Lang = "Eng" ElseIf InStr(c, ":") &gt; 0 Then stGotIt = StrReverse(c) stGotIt = Left(c, InStr(1, c, " ", vbTextCompare)) The_Shift_End = StrReverse(Trim(stGotIt)) stGotIt = Left(The_Shift, InStr(1, The_Shift, " ", vbTextCompare)) The_Shift_Start = stGotIt stCell = ReturnAvailabilityEnglish(The_Time, The_Shift_Start, The_Shift_End) ' this is the line causing the error End If Next c Next r ReturnAvailability = Counter End Function Function ReturnAvailabilityEnglish(The_Time As String, The_Shift_Start As String, The_Shift_End As String) Dim Time_Hour As Integer Dim Time_Min As Integer Dim Start_Hour As Integer Dim Start_Min As Integer Dim End_Hour As Integer Dim End_Min As Integer Dim Available As Integer Available = 13 Time_Hour = CInt(Left(The_Time, 2)) Time_Min = CInt(Right(The_Time, 2)) Start_Hour = CInt(Left(The_Shift_Start, 2)) Start_Min = CInt(Right(The_Shift_Start, 2)) End_Hour = CInt(Left(The_Shift_End, 2)) End_Min = CInt(Right(The_Shift_End, 2)) If Start_Hour &lt;= Time_Hour And Start_Min &lt;= Time_Min Then If End_Hour &gt; Time_Hour And End_Min &gt; Time_Min Then Available = 1 Else Available = 0 End If End If ReturnAvailabilityEnglish = Available End Function </code></pre> <p>Thanks, Darragh J</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload