通过 VBA 选择 Range 类的方法失败 [英] Select method of Range class failed via VBA
本文介绍了通过 VBA 选择 Range 类的方法失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我目前正在使用的代码,我遇到了这个问题.我是 Excel 新手,不知道出了什么问题.
This is the code that I'm currently working with, and I'm getting this problem. I'm novice at Excel and I can't figure out what's wrong.
Private Sub cmdRecord_Click()
Sheets("BxWsn Simulation").Range("Result").Select //This is the line with the problem, as excel told me.
Selection.Copy
Sheets("Reslt Record").Select
Sheets("Reslt Record").Range("A5000").End(xlUp).Offset(1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Sheets("CuCon Simulator").Select
Application.CutCopyMode = False
Range("Improvement").Select
End Sub
错误是Range类的Select方法通过VBA失败,错误1004
.有什么想法吗?
The error is Select method of Range class failed via VBA, Error 1004
.
Any ideas?
预计到达时间:
所以我只是把代码改成
Sheets("BxWsn Simulation").Select
Range("Result").Select
我相信这就是您所说的让它活跃的意思吗?
I believe this is what you mean by making it active?
但是我仍然遇到对象_Worksheet"的方法范围"失败,错误1004
.
推荐答案
我相信你有 同样的问题在这里.
工作表必须处于活动状态,您才能在其上选择范围.
I believe you are having the same problem here.
The sheet must be active before you can select a range on it.
另外,不要省略工作表名称限定符:
Also, don't omit the sheet name qualifier:
Sheets("BxWsn Simulation").Select
Sheets("BxWsn Simulation").Range("Result").Select
或者,
With Sheets("BxWsn Simulation")
.Select
.Range("Result").Select
End WIth
这是一样的.
这篇关于通过 VBA 选择 Range 类的方法失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文