|
Sub CommandButton1_Click() '一本二本三本入围与出局
Dim i As Integer
Application.ScreenUpdating = False
For i = 0 To 2
a = Range("B65536").End(xlUp).Row + 1 '最后行数
' Range("B3:N" & a).ClearContents '清除原有数据
x = Sheets("文科").Range("A65536").End(xlUp).Row '最后行数
n1 = Sheets("设置").Cells(16 + i, 3).Value '语文入围分
n2 = Sheets("设置").Cells(16 + i, 4).Value
n3 = Sheets("设置").Cells(16 + i, 5).Value
n4 = Sheets("设置").Cells(16 + i, 6).Value
n5 = Sheets("设置").Cells(16 + i, 7).Value
n6 = Sheets("设置").Cells(16 + i, 8).Value
n7 = Sheets("设置").Cells(16 + i, 9).Value '总分入围分
With CreateObject("adodb.connection")
.Open "provider=microsoft.jet.oledb.4.0;extended properties='Excel 8.0;hdr=yes;';data source=" & ThisWorkbook.FullName
Cells(3 + i * 20, 2).CopyFromRecordset .Execute("select 班级,sum(语文>=" & n1 & ")*(-1),sum((语文<" & n1 & ")*(总分>=" & n7 & ")) from[文科$A1:w" & x & "] group by 班级 ")
.Close
End With
文理分析7-3.rar
(59.36 KB, 下载次数: 14)
Next i
Range("c16").Value = "=sum(c3:c15)" '这里能不能自动求和
Application.ScreenUpdating = True
End Sub
班级排序不是1班,2班,如何处理???
|
|