|
▼ブーちゃん さん:
前回のFunctionを以下のものに変更してください。
Function CheckDat(ws As Worksheet, RR&) As String
'長いと見づらいので変数(配列)に格納して処理
Dim c(1 To 5) As Variant, res$
With ws
c(1) = .Cells(RR&, 11).Value
c(2) = .Cells(RR&, 13).Value
c(3) = .Cells(RR&, 14).Value
c(4) = .Cells(RR&, 18).Value
'c(5) = .Cells(RR&, 5番目条件の列番号).Value
End With
res$ = "分岐指定ミス"
'
'難しいことは考えず、ベタに分岐します。
If (c(1) = 1) And (c(2) = "A") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN1 何も表示しない定義
ElseIf (c(1) = 2) And (c(2) = "A") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN2 何も表示しない定義
ElseIf (c(1) = 1) And (c(2) = "A") And (c(3) = 0) And (c(4) = 1) Then
res$ = "": 'LN3 何も表示しない定義
ElseIf (c(1) = 1) And (c(2) = "A") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN4 何も表示しない定義
ElseIf (c(1) = 0) And (c(2) = "A") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN5 何も表示しない定義
ElseIf (c(1) = 0) And (c(2) = "B") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN6 何も表示しない定義
ElseIf (c(1) = 2) And (c(2) = "B") And (c(3) = 0) And (c(4) = 1) Then
res$ = "": 'LN7 何も表示しない定義
ElseIf (c(1) = 1) And (c(2) = "B") And (c(3) = 0) And (c(4) = 1) Then
res$ = "": 'LN8 何も表示しない定義
ElseIf (c(1) = 2) And (c(2) = "B") And (c(3) = 0) And (c(4) = 1) Then
res$ = "": 'LN9 何も表示しない定義
ElseIf (c(1) = 0) And (c(2) = "B") And (c(3) = 1) And (c(4) = 1) Then
res$ = "": 'LN10 何も表示しない定義
ElseIf (c(1) = 0) And (c(2) = "B") And (c(3) = 0) And (c(4) = 1) Then
res$ = "": 'LN11 何も表示しない定義
'ElseIf 条件12 Then
' res$ = "": 'LN12 何も表示しない定義
'ElseIf 条件13 Then
' res$ = "": 'LN13 何も表示しない定義
'ElseIf 条件14 Then
' res$ = "": 'LN14 何も表示しない定義
'↓不具合
ElseIf (c(1) = 1) And (c(2) = "A") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L15 不具合"
ElseIf (c(1) = 2) And (c(2) = "A") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L16 不具合"
ElseIf (c(1) = 1) And (c(2) = "A") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L17 不具合"
ElseIf (c(1) = 2) And (c(2) = "A") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L18 不具合"
ElseIf (c(1) = 0) And (c(2) = "A") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L19 不具合"
ElseIf (c(1) = 0) And (c(2) = "A") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L20 不具合"
ElseIf (c(1) = 0) And (c(2) = "A") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L21 不具合"
'ElseIf 条件22 Then
' res$ = "L22 不具合"
ElseIf c(2) = "A" Then
res$ = "L23 不具合"
ElseIf (c(1) = 1) And (c(2) = "B") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L24 不具合"
ElseIf (c(1) = 2) And (c(2) = "B") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L25 不具合"
ElseIf (c(1) = 1) And (c(2) = "B") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L26 不具合"
ElseIf (c(1) = 2) And (c(2) = "B") And (c(3) = 0) And (c(4) = 0) Then
res$ = "L27 不具合"
ElseIf (c(1) = 0) And (c(2) = "B") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L28 不具合"
ElseIf (c(1) = 0) And (c(2) = "B") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L29 不具合"
ElseIf (c(1) = 1) And (c(2) = "C") And (c(4) = 0) Then
res$ = "L30 不具合"
ElseIf (c(1) = 2) And (c(2) = "C") And (c(4) = 0) Then
res$ = "L31 不具合"
ElseIf (c(1) = 0) And (c(2) = "D") And (c(3) = 1) And (c(4) = 0) Then
res$ = "L32 不具合"
ElseIf (c(1) = 1) And (c(2) = "D") Then
res$ = "L33 不具合"
ElseIf (c(1) = 2) And (c(2) = "D") Then
res$ = "L34 不具合"
'ElseIf 条件35 Then
' res$ = "L35 不具合"
'ElseIf 条件36 Then
' res$ = "L36 不具合"
'ElseIf 条件37 Then
' res$ = "L37 不具合"
End If
Erase c
'
CheckDat = res$
End Function
定義漏れの分岐がないですけどね。
この分岐でヒットしなかったものを定義漏れとするならば、分岐指定ミス を 定義漏れ に変更してください。
|
|