当我编译这个脚本时,宏有时会混淆范围,我得到错误1004,即使我将其粘贴到不同的工作表中,复制粘贴区域也不能相同。感谢有人能让我知道我哪里出错了
Dim LastRow1 As Long
With Worksheets("1")
LastRow1 = .Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:EE" & LastRow1).Copy
End With
Worksheets("3").Activate
Range("A1").PasteSpecial Transpose:=True
MsgBox ("Transpose Completed")
答案 0 :(得分:0)
我建议您检查和更新您的宏,如下所示。
Sub TransposeData()
Dim LastRow1 As Long
With Worksheets("1")
LastRow1 = .Cells(Rows.Count, "A").End(xlUp).Row
If LastRow1 > 16384 Then
MsgBox "Transpose not possible, number of columns will be exceeded!", vbExclamation
Exit Sub
End If
.Range("A1:EE" & LastRow1).Copy
End With
Worksheets("3").Range("A1").PasteSpecial Transpose:=True
Application.CutCopyMode = False
MsgBox ("Transpose Completed")
End Sub