Sub 汇总()
Application.ScreenUpdating = False
Dim x As Long
Dim y As Long
Dim i1 As Long
Dim j1 As Long
For x = 1 To Sheets.Count - 1
If Sheets(x).Name <> ActiveSheet.Name Then
For y = 1 To Sheets(x).UsedRange.Rows.Count
i1 = 1
j1 = 1
Do
i1 = i1 + 1
If Sheets("com").Cells(1, i1).Value = Sheets(x).Cells(y, 1).Value Then
Exit Do
End If
Loop
Do
j1 = j1 + 1
If Sheets("com").Cells(j1, 1).Value = Sheets(x).Cells(y, 3).Value Then
Worksheets(x).Cells(x, 4).Copy Sheets("com").Cells(i1, j1)
Exit Do
End If
Loop
Next
End If
Next
Range("A1").Select
Application.ScreenUpdating = True
End Sub
源代码如上,我打算做一个将多sheet数据导入单sheet的代码(多sheet与单sheet格式不同),但是在" If Sheets("com").Cells(1, i1).Value = Sheets(x).Cells(y, 1).Value Then"句一直报错(错误5)。大佬帮忙看一下到底是错在哪儿了,谢谢。