简体   繁体   English

Excel VBA使用范围与变量

[英]Excel VBA using Range with variables

I am trying to clear a range of cells with the use of a variable. 我正在尝试使用变量来清除一系列单元格。 For some background I have values in AG that will be updated regularly while the values in IK need to remain constant. 对于某些背景,AG中的值会定期更新,而IK中的值需要保持不变。

I am trying to use the value stored in myCell (in this example A8) to guide my clear command to be everything from it to G100 我正在尝试使用存储在myCell中的值(在本示例中为A8)来指导我的clear命令,使其成为从G100到G100的所有内容

Range(myCell, "G100").ClearContents

I have tried several variations of this but it never seems to take so there must be something I am missing. 我已经尝试了几种变体,但是似乎从来没有做过,因此肯定有我缺少的东西。

Thanks for looking! 感谢您的光临!

你近了

Range(myCell, range("G100")).ClearContents

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM