以下は私が書いたコードですが、コメントを追加した行とその行だけに問題があります。私は他のすべての行をコメントし、問題の行としてこれを分離しましたが、私の人生と私がやった1時間以上の研究では、問題の内容を理解できません。それはおそらく本当に明白なものですが、私は本当に立ち往生しており、それは私を夢中にしています。とにかく 別の関数内からVBA関数を呼び出す問題
は、コードはシフト時間と言語機能を含んだデータの範囲を取り、 (下記のコードでThe_Timeを)与えられた期間内に特定の言語を持つ多くの人々が利用可能であるかを示すために使用されるべきですご迷惑をおかけして申し訳ございません。
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") > 0 Then
The_Lang = "Eng"
ElseIf InStr(c, ":") > 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 <= Time_Hour And Start_Min <= Time_Min Then
If End_Hour > Time_Hour And End_Min > Time_Min Then
Available = 1
Else
Available = 0
End If
End If
ReturnAvailabilityEnglish = Available
End Function
おかげで、 Darragh J
エラーの原因は次のうちどれですか?それはコンパイルエラーかランタイムエラーですか? –
申し訳ありませんが、コメントが追加されました –
エラーは何ですか? – BenV