我在切割多张工作表并把它放在一个表上有问题。我得到了“类型错配”错误。你能看看我的密码吗?
Public Sub Conc()
Dim ws As Worksheet
Dim LR1 As Integer
Dim LR2 As Integer
Dim LR3 As Integer
Dim first As Integer
LR1 = 0
LR2 = 0
LR3 = 0
first = 1
With ThisWorkbook
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Conc"
End With
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Conc" Then
LR1 = Sheets("Conc").Cells(Rows.Count, 2).End(xlUp).Row + 1
LR2 = ws.Cells(Rows.Count, 2).End(xlUp).Row
LR3 = LR1 + LR2
Worksheets(ws).Rows(first & ":" & LR2).Cut
Worksheets("Conc").Rows(LR1 & ":" & LR3).Insert
End If
Next ws
End Sub发布于 2020-02-19 12:44:44
尝试:
Public Sub Conc()
Dim ws As Worksheet
Dim LR1 As Long, LR2 As Log, LR3 As Long
Dim first As Integer
LR1 = 0
LR2 = 0
LR3 = 0
first = 1
With ThisWorkbook
.Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Conc"
End With
With ThisWorkbook.Worksheets("Conc")
LR1 = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
End With
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Conc" Then
With ws
LR2 = .Cells(.Rows.Count, 2).End(xlUp).Row
LR3 = LR1 + LR2
.Rows(first & ":" & LR2).Cut
End With
ThisWorkbook.Worksheets("Conc").Rows(LR1 & ":" & LR3).Insert
End If
Next ws
End Subhttps://stackoverflow.com/questions/60300266
复制相似问题