|
判断一个区域内,当b1为幼儿园时,c1的值应该在托班、小班、中班、大班中选择;当b1为小学时,c1的值应该在一至六之间……如果不在相应的范围内,返回所在的行号。
应该怎么做,刚才用了select和if组合,得不到正确答案
Sub 班级判断()
Dim row1 As Integer
row1 = Cells(Rows.Count, 2).End(xlUp).Row
For i = 6 To row1
Select Case Cells(i, 9)
Case "幼儿园"
If Cells(i, 9).Offset(0, 1) = "托班" Or Cells(i, 9).Offset(0, 1) = "小班" Or Cells(i, 9).Offset(0, 1) = "中班" Or Cells(i, 9).Offset(0, 1) = "大班" Then
Else
s1 = s1 & i & ","
End If
Case "小学"
If Cells(i, 9).Offset(0, 1) = "一" Or Cells(i, 9).Offset(0, 1) = "二" Or Cells(i, 9).Offset(0, 1) = "三" Or Cells(i, 9).Offset(0, 1) = "四" Or Cells(i, 9).Offset(0, 1) = "五" Or Cells(i, 9).Offset(0, 1) = "六" Then
Else
s2 = s2 & i & ","
End If
End Select
Next
s5 = s1 & s2
s6 = Left(s5, Len(s5) - 1)
If s1 = "" Then
MsgBox "学段项没有错误"
Else
MsgBox "第" & s6 & "行有错误"
End If
End Sub
|
|