VBA에는 다음 두 가지 기능이 있습니다. 그리고 나의 탁월함은 이것처럼 보일 것입니다.for 루프에 조건 추가
OddsId Agt Ma Sma Result
1 Agt1 Ma1 Sma1 x
제 의도는 x의 값을 계산하는 것입니다. 그리고 나는 조건을 추가하고 싶습니다. 사용자는 Agt, ma 및 Sma 중에서 한 번에 하나의 값만 제공 할 수 있습니다. 이 두 필드 중 하나라도 0이 아니면 결과에 "Error"가 표시됩니다. 이 함수에이 조건을 추가 할 위치를 모르겠습니다.
나는 또한 무엇을 할 지 모르겠다. 친절하게 도와주세요. 여기
Function fcComm1(oddsId As Integer, agt As String, ma As String, sma As String, fcOption1 As Integer)
If Not setFcType(agt, ma, sma) Then
fcComm1 = "Invalid2"
Return
End If
For i = 1 To bets.ListRows.Count
currOddsId = bets.ListColumns("OddsId").DataBodyRange(i)
currTransId = bets.ListColumns("TransId").DataBodyRange(i)
currPlayer = bets.ListColumns("Account").DataBodyRange(i)
If (currOddsId = oddsId) Then
If FcType = "agt" Then
currAgt = Application.WorksheetFunction.VLookup(currPlayer, accounts.DataBodyRange, 9, False)
If (agt <> currAgt) Then
fcComm1 = ""
GoTo NextIteration
End If
ElseIf FcType = "ma" Then
currMa = Application.WorksheetFunction.VLookup(currPlayer, accounts.DataBodyRange, 10, False)
If (ma <> currMa) Then
fcComm1 = ""
GoTo NextIteration
End If
ElseIf FcType = "sma" Then
currSma = Application.WorksheetFunction.VLookup(currPlayer, accounts.DataBodyRange, 11, False)
If (sma <> currSma) Then
fcComm1 = ""
GoTo NextIteration
End If
End If
exchangeRate = Application.WorksheetFunction.VLookup(currPlayer, accounts.DataBodyRange, 4, False)
blindRisk = Application.WorksheetFunction.VLookup(currPlayer, accounts.DataBodyRange, 6, False)/100#
fcComm1 = fcComm1 + ForecastBet(currTransId, exchangeRate, blindRisk)
NextIteration:
End If
Next
End Function
Function setFcType(agt As String, ma As String, sma As String)
setFcType = True
If Len(agt) + Len(ma) + Len(sma) = 0 Then
FcType = "company"
ElseIf agt <> "" And agt <> "0" Then
FcType = "agt"
ElseIf ma <> "" And ma <> "0" Then
FcType = "ma"
ElseIf sma <> "" And sma <> "0" Then
FcType = "sma"
End If
End Function
참고 : 여기에 코드를 붙여 넣을 때 모든 변수가 올바르게 정의되어 있습니다. 현재이 코드는 잘 작동합니다. 나는 someconditions를 추가 할 필요가있다. Thnks. – Shan