昨天问题解决,今天出现新问题,求高手解答
第一个按钮代码Private Sub Command1_Click()
Dim EXAPP As Excel.Application
Dim WB As Excel.Workbook
Dim sht As Excel.Worksheet
Set EXAPP = CreateObject("excel.application")
Set WB = EXAPP.Workbooks.Open("d:\成绩表.xls")
Set sht = WB.Worksheets("Sheet1")
Range("N2").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-8]:RC[-1])"
Range("N2").Select
Selection.AutoFill Destination:=Range("N2:N641"), Type:=xlFillDefault
Range("N2:N641").Select
ActiveWindow.SmallScroll Down:=-9
Form1.Caption = sht.Range("B5").Value '从表格取值
'WB.Save'保存编辑后的文件
WB.Close
Set sht = Nothing
Set WB = Nothing
Set EXAPP = Nothing
End Sub
第二个按钮代码
Private Sub Command2_Click()
Dim EXAPP As Excel.Application
Dim WB As Excel.Workbook
Dim sht As Excel.Worksheet
Set EXAPP = CreateObject("excel.application")
Set WB = EXAPP.Workbooks.Open("d:\成绩表.xls")
Set sht = WB.Worksheets("总表")
sht.Range("U3").Select
ActiveCell.FormulaR1C1 = "=RANK(RC[-1],R3C20:R800C20)"
Set sht = Nothing
Set WB = Nothing
Set EXAPP = Nothing
End Sub
昨天问题解决了
但是如果在第二按钮中计算的加入ActiveCell.FormulaR1C1 = "=RANK(RC[-1],R3C20:R800C20)"这个公式计算就提示错误,问题所在不懂!求教高手解答。