资源描述:
《vba算成绩程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Sub算成绩()m=InputBox("请输入年级如1、2、3、4、5、6")'记录年级Dimxx(1To8)AsStringxx(1)="南村1":xx(2)="南村2":xx(3)="兴中":xx(4)="东风":xx(5)="西沟":xx(6)="峪头":xx(7)="普乐塬":xx(8)="尧场"Dimkmb(1To3)AsStringkmb(1)="语":kmb(2)="数":kmb(3)="英"Forq=1To8Sheets(xx(q)).Activate'计算成绩n=Application.WorksheetFunctio
2、n.CountA(Range("A2:A60"))-11'记录考试人数l=Application.WorksheetFunction.Match("语文",Range("a2:e2"),0)'记录"语文"所在列数ywzf=Application.WorksheetFunction.Sum(Range(Cells(3,l),Cells(n+2,l)))'语文总分sxzf=Application.WorksheetFunction.Sum(Range(Cells(3,l+1),Cells(n+2,l+1)))'数学总分ywjg=Applic
3、ation.WorksheetFunction.CountIf(Range(Cells(3,l),Cells(n+2,l)),">59")'语文及格人数sxjg=Application.WorksheetFunction.CountIf(Range(Cells(3,l+1),Cells(n+2,l+1)),">59")'数学及格人数ywyx=Application.WorksheetFunction.CountIf(Range(Cells(3,l),Cells(n+2,l)),">79")'语文优秀人数sxyx=Application.
4、WorksheetFunction.CountIf(Range(Cells(3,l+1),Cells(n+2,l+1)),">79")'数学优秀人数Ifm>2Thenyyzf=Application.WorksheetFunction.Sum(Range(Cells(3,l+2),Cells(n+2,l+2)))'英语总分yyjg=Application.WorksheetFunction.CountIf(Range(Cells(3,l+2),Cells(n+2,l+2)),">59")'英语及格人数yyyx=Application.W
5、orksheetFunction.CountIf(Range(Cells(3,l+2),Cells(n+2,l+2)),">79")'英语优秀人数EndIf'在成绩单上输出成绩Cells(n+3,l)=ywzf:Cells(n+3,l+1)=sxzf'语文、数学总分Cells(n+4,l)=Round(ywzf/n,2)'语文、数学均分Cells(n+4,l+1)=Round(sxzf/n,2)Cells(n+5,l)=Round(Cells(n+4,l)*0.6,2)'语文、数学均分折分Cells(n+5,l+1)=Round(Cel
6、ls(n+4,l+1)*0.6,2)Cells(n+6,l)=ywjg:Cells(n+6,l+1)=sxjg'语文、数学及格人数Cells(n+7,l)=Round(ywjg/n*100,2)'语文、数学及格率Cells(n+7,l+1)=Round(sxjg/n*100,2)Cells(n+8,l)=Round(Cells(n+7,l)*0.25,2)'语文、数学及格率折分Cells(n+8,l+1)=Round(Cells(n+7,l+1)*0.25,2)Cells(n+9,l)=ywyx:Cells(n+9,l+1)=sxyx'
7、语文、数学优秀人数Cells(n+10,l)=Round(ywyx/n*100,2)'语文、数学优秀率Cells(n+10,l+1)=Round(sxyx/n*100,2)Cells(n+11,l)=Round(Cells(n+10,l)*0.15,2)'语文、数学优秀率折分Cells(n+11,l+1)=Round(Cells(n+10,l+1)*0.15,2)Cells(n+12,l)=Cells(n+5,l)+Cells(n+8,l)+Cells(n+11,l)'语文、数学积分Cells(n+12,l+1)=Cells(n+5,l
8、+1)+Cells(n+8,l+1)+Cells(n+11,l+1)Ifm>2Then'英语科Cells(n+3,l+2)=yyzfCells(n+4,l+2)=Round(yyzf/n,2)Cells(n