对象在2个工作簿之间复制和粘贴所需的错误

发布于 2025-01-27 14:33:26 字数 1105 浏览 2 评论 0原文

    Sub CriticalSummerList()



Dim wb1 As Workbook
Dim ws1 As Worksheet

Set wb1 = Workbooks("1")
Set ws1 = wb1.Sheets("Sheet1")


Set wb2 = Workbooks.Open("G:\")
Set ws2 = wb2.Sheets("Sheet1")

Set rng = [B1]
Set rng = Range(rng, Cells(Rows.Count, rng.Column).End(xlUp))

ws2.Select
rng.TextToColumns Destination:=rng, DataType:=xlDelimited

    With Range("b1").CurrentRegion
        .Sort Key1:=.Range("b1"), Order1:=xlAscending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    End With
 
Set ws3 = wb2.Sheets("Sheet2")
 
ws3.Activate

Dim Lastrow As Integer
Lastrow = Cells(Rows.Count, "b").End(xlUp).Offset(0, 0).Row

With ws3
.Range("e2:l" & Lastrow).Copy
End With

wb1.Activate
ws1.Range("E3").Select

wb1.ws1.Paste ws1.[e3]



 
 

End Sub

我将WB2.WS2上的范围设置为texttoColumn范围B:b。 从WS3 E2:L到最后一行并粘贴到WB1.WS1。 当我粘贴时,我遇到了这个错误。我尝试了所有其他方法来粘贴数据,但是它不断抛出对象所需的错误。感谢您的帮助。 我将WB2.WS2上的范围设置为texttoColumn范围B:b。 从WS3 E2:L到最后一行并粘贴到WB1.WS1。 当我粘贴时,我遇到了这个错误。我尝试了所有其他方法来粘贴数据,但是它不断抛出对象所需的错误。感谢您的帮助。

    Sub CriticalSummerList()



Dim wb1 As Workbook
Dim ws1 As Worksheet

Set wb1 = Workbooks("1")
Set ws1 = wb1.Sheets("Sheet1")


Set wb2 = Workbooks.Open("G:\")
Set ws2 = wb2.Sheets("Sheet1")

Set rng = [B1]
Set rng = Range(rng, Cells(Rows.Count, rng.Column).End(xlUp))

ws2.Select
rng.TextToColumns Destination:=rng, DataType:=xlDelimited

    With Range("b1").CurrentRegion
        .Sort Key1:=.Range("b1"), Order1:=xlAscending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal
    End With
 
Set ws3 = wb2.Sheets("Sheet2")
 
ws3.Activate

Dim Lastrow As Integer
Lastrow = Cells(Rows.Count, "b").End(xlUp).Offset(0, 0).Row

With ws3
.Range("e2:l" & Lastrow).Copy
End With

wb1.Activate
ws1.Range("E3").Select

wb1.ws1.Paste ws1.[e3]



 
 

End Sub

I'm setting the range on wb2.ws2 to texttocolumn range B:B.
Copy from ws3 e2:L to last row and paste to wb1.ws1.
It is when i paste that i come across this error. I tried all other ways to paste the data however it keeps throwing object required error. Thank you for your help.
I'm setting the range on wb2.ws2 to texttocolumn range B:B.
Copy from ws3 e2:L to last row and paste to wb1.ws1.
It is when i paste that i come across this error. I tried all other ways to paste the data however it keeps throwing object required error. Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文