运行时错误'1004':选择范围类失败的方法VBA 2003 [英] Run Time Error '1004': Select method of Range Class failed VBA 2003

查看:160
本文介绍了运行时错误'1004':选择范围类失败的方法VBA 2003的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将列从一张表复制到另一张。我使用的代码是一个记录的宏,它可以正常工作,直到我连接到一个按钮。当我这样做时,它会产生一个运行时错误1004':选择范围类失败的方法

I am trying to copy a column from one sheet to another. The code I am using is a recorded macro and it works fine until I connect it to a button. When I do so, it gives a "Run Time Error '1004': Select method of Range Class failed"

这是代码和我可以看出没有错。当我点击调试它突出显示第二行。

Here is the code and I can see nothing wrong with it. When I hit debug it highlights the second line.

Sheets("Count").Select
Columns("C:C").Select
Selection.Copy
Sheets("Add Invintory").Select
Range("b1").Select
ActiveSheet.Paste
Sheets("Count").Select
Sheets("Count").Columns("A:A").Select
Columns("A:A").Select
Selection.Copy
Sheets("Add Invintory").Select
Range("A1").Select
ActiveSheet.Paste

我不知道问题是什么。请帮助

I have no clue what the problem is. Please help

推荐答案

您应该始终避免使用。选择他们是主要原因:)

You should always avoid using .Select They are a major cause of errors :)

您是否尝试过这个?

Sub Sample()
    Sheets("Count").Columns("C:C").Copy _
    Sheets("Add Invintory").Columns("B:B")

    Sheets("Count").Columns("A:A").Copy _
    Sheets("Add Invintory").Columns("A:A")
End Sub

这篇关于运行时错误'1004':选择范围类失败的方法VBA 2003的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆