Sub test()
Dim avg As Variant
For x =1 To 8
Select Case True
Case ThisWorkbook.Sheets(1).Cells(x,1).Value ="" And ThisWorkbook.Sheets(1).Cells(x,2).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,3).Value <>""
avg =(ThisWorkbook.Sheets(1).Cells(x,2).Value + ThisWorkbook.Sheets(1).Cells(x,3).Value)/2
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,2).Value ="" And ThisWorkbook.Sheets(1).Cells(x,3).Value <>""
avg =(ThisWorkbook.Sheets(1).Cells(x,1).Value + ThisWorkbook.Sheets(1).Cells(x,3).Value)/2
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,2).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,3).Value =""
avg =(ThisWorkbook.Sheets(1).Cells(x,1).Value + ThisWorkbook.Sheets(1).Cells(x,2).Value)/2
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value ="" And ThisWorkbook.Sheets(1).Cells(x,2).Value ="" And ThisWorkbook.Sheets(1).Cells(x,3).Value <>""
avg = ThisWorkbook.Sheets(1).Cells(x,3).Value
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,2).Value ="" And ThisWorkbook.Sheets(1).Cells(x,3).Value =""
avg = ThisWorkbook.Sheets(1).Cells(x,1).Value
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value ="" And ThisWorkbook.Sheets(1).Cells(x,2).Value <>"" And ThisWorkbook.Sheets(1).Cells(x,3).Value =""
avg = ThisWorkbook.Sheets(1).Cells(x,2).Value
Debug.Print avg
Case ThisWorkbook.Sheets(1).Cells(x,1).Value ="" And ThisWorkbook.Sheets(1).Cells(x,2).Value ="" And ThisWorkbook.Sheets(1).Cells(x,3).Value =""
avg ="没有数据"
Debug.Print avg
Case Else
avg =(ThisWorkbook.Sheets(1).Cells(x,1).Value + ThisWorkbook.Sheets(1).Cells(x,2).Value + ThisWorkbook.Sheets(1).Cells(x,3).Value)/3
Debug.Print avg
End Select
Next x
End Sub
Sub test() result = Array("G35", "N23", "N31") mole_arr = Array(32, 29, 68) '分子 deno_arr = Array(29, 23, 65) '分母 Dim cell_result As Variant, mole_result As Variant, deno_result As Vari...