vba 运行出错(运行时错误‘1004’)调试没错误,我不知道哪句出错了?
Subqs()Application.DisplayAlerts=FalseApplication.ScreenUpdating=FalseForch=4ToRange(...
Sub qs()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For ch = 4 To Range("A65536").End(xlUp).Row
bj = Range("A" & ch).Value
mfile = ThisWorkbook.Path + "\" & Left(bj, 1) + "年级\" & Left(bj, 1) + "年级.xls"
If Dir(mfile) <> "" Then
bs = 0
Do While InStr(Range("A" & ch + bs).Value, Left(bj, 1))
bs = bs + 1
Loop
Workbooks.Open (mfile)
For i = 1 To bs
sj = ActiveSheet.Range("A:A").Find(Left(bj, 1) & "(" + CStr(i) & ")").Row
With Workbooks(1).Sheets(1)
.Range("B" & ch) = ActiveSheet.Range("B" & sj)
.Range("D" & ch) = ActiveSheet.Range("C" & sj)
.Range("F" & ch) = ActiveSheet.Range("D" & sj)
.Range("H" & ch) = ActiveSheet.Range("E" & sj)
.Range("E" & ch).Formula = "=Round($B" & ch & "* F" & ch & ",0)"
.Range("E" & ch).Copy .Range("G" & ch)
.Range("L" & ch) = ActiveSheet.Range("G" & sj)
.Range("N" & ch) = ActiveSheet.Range("H" & sj)
.Range("P" & ch) = ActiveSheet.Range("I" & sj)
.Range("E" & ch).Copy .Range("M" & ch)
.Range("E" & ch).Copy .Range("O" & ch)
If ActiveSheet.Range("K" & sj) > "" Then
.Range("T" & ch) = ActiveSheet.Range("K" & sj)
.Range("V" & ch) = ActiveSheet.Range("L" & sj)
.Range("X" & ch) = ActiveSheet.Range("M" & sj)
.Range("E" & ch).Copy .Range("U" & ch)
.Range("E" & ch).Copy .Range("W" & ch)
End If
If ActiveSheet.Range("O" & sj) > "" Then
.Range("AB" & ch) = ActiveSheet.Range("O" & sj)
.Range("AD" & ch) = ActiveSheet.Range("P" & sj)
.Range("AF" & ch) = ActiveSheet.Range("Q" & sj)
.Range("E" & ch).Copy .Range("AC" & ch)
.Range("E" & ch).Copy .Range("AE" & ch)
End If
If ActiveSheet.Range("S" & sj) > "" Then
.Range("AJ" & ch) = ActiveSheet.Range("S" & sj)
.Range("AL" & ch) = ActiveSheet.Range("T" & sj)
.Range("AN" & ch) = ActiveSheet.Range("U" & sj)
.Range("E" & ch).Copy .Range("AK" & ch)
.Range("E" & ch).Copy .Range("AM" & ch)
End If
End With
ch = ch + 1
Next
ActiveWorkbook.Close
Workbooks(1).Sheets(1).Activate
Range("I" & ch).Formula = "=IF(ISERROR(AVERAGE(I" & ch - bs & ":I" & ch - 1 & "))," & Chr(34) & Chr(34) & ",AVERAGE(I" & ch - bs & ":I" & ch - 1 & "))"
Cells(ch, 9).Copy Cells(ch, 17)
Cells(ch, 9).Copy Cells(ch, 25)
Cells(ch, 9).Copy Cells(ch, 33)
Cells(ch, 9).Copy Cells(ch, 41)
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub 展开
Application.DisplayAlerts = False
Application.ScreenUpdating = False
For ch = 4 To Range("A65536").End(xlUp).Row
bj = Range("A" & ch).Value
mfile = ThisWorkbook.Path + "\" & Left(bj, 1) + "年级\" & Left(bj, 1) + "年级.xls"
If Dir(mfile) <> "" Then
bs = 0
Do While InStr(Range("A" & ch + bs).Value, Left(bj, 1))
bs = bs + 1
Loop
Workbooks.Open (mfile)
For i = 1 To bs
sj = ActiveSheet.Range("A:A").Find(Left(bj, 1) & "(" + CStr(i) & ")").Row
With Workbooks(1).Sheets(1)
.Range("B" & ch) = ActiveSheet.Range("B" & sj)
.Range("D" & ch) = ActiveSheet.Range("C" & sj)
.Range("F" & ch) = ActiveSheet.Range("D" & sj)
.Range("H" & ch) = ActiveSheet.Range("E" & sj)
.Range("E" & ch).Formula = "=Round($B" & ch & "* F" & ch & ",0)"
.Range("E" & ch).Copy .Range("G" & ch)
.Range("L" & ch) = ActiveSheet.Range("G" & sj)
.Range("N" & ch) = ActiveSheet.Range("H" & sj)
.Range("P" & ch) = ActiveSheet.Range("I" & sj)
.Range("E" & ch).Copy .Range("M" & ch)
.Range("E" & ch).Copy .Range("O" & ch)
If ActiveSheet.Range("K" & sj) > "" Then
.Range("T" & ch) = ActiveSheet.Range("K" & sj)
.Range("V" & ch) = ActiveSheet.Range("L" & sj)
.Range("X" & ch) = ActiveSheet.Range("M" & sj)
.Range("E" & ch).Copy .Range("U" & ch)
.Range("E" & ch).Copy .Range("W" & ch)
End If
If ActiveSheet.Range("O" & sj) > "" Then
.Range("AB" & ch) = ActiveSheet.Range("O" & sj)
.Range("AD" & ch) = ActiveSheet.Range("P" & sj)
.Range("AF" & ch) = ActiveSheet.Range("Q" & sj)
.Range("E" & ch).Copy .Range("AC" & ch)
.Range("E" & ch).Copy .Range("AE" & ch)
End If
If ActiveSheet.Range("S" & sj) > "" Then
.Range("AJ" & ch) = ActiveSheet.Range("S" & sj)
.Range("AL" & ch) = ActiveSheet.Range("T" & sj)
.Range("AN" & ch) = ActiveSheet.Range("U" & sj)
.Range("E" & ch).Copy .Range("AK" & ch)
.Range("E" & ch).Copy .Range("AM" & ch)
End If
End With
ch = ch + 1
Next
ActiveWorkbook.Close
Workbooks(1).Sheets(1).Activate
Range("I" & ch).Formula = "=IF(ISERROR(AVERAGE(I" & ch - bs & ":I" & ch - 1 & "))," & Chr(34) & Chr(34) & ",AVERAGE(I" & ch - bs & ":I" & ch - 1 & "))"
Cells(ch, 9).Copy Cells(ch, 17)
Cells(ch, 9).Copy Cells(ch, 25)
Cells(ch, 9).Copy Cells(ch, 33)
Cells(ch, 9).Copy Cells(ch, 41)
End If
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub 展开
1个回答
金山毒霸
2024-10-31 广告
2024-10-31 广告
电脑在启动游戏或软件的时候,桌面弹出错误提示框“0xc0000094”,应该怎么办?电脑报错,很大可能是因为某些DLL文件出现了异常,比如感染了病毒、DLL文件丢失等。解决方法如下:一、 手动解决方法1、先确定电脑操作系统是多少位的,现在的...
点击进入详情页
本回答由金山毒霸提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询