简体   繁体   English

在VBA中,是否可以选择相对于动态范围的单元格?

[英]In VBA, is it possible to select a cell relative to a dynamic range?

Let's say I set 'Rng' as a dynamic range, like ("A" & i) where 'i=2' and i increases by 1 whenever a certain condition is met. 假设我将“ Rng”设置为动态范围,例如(“ A”&i),其中'i = 2',并且只要满足特定条件,i就会增加1。 At the same time, I also set 'k = 2' and increase k whenever another condition is met. 同时,我还设置了“ k = 2”,并在满足其他条件时增加k。 Is it possible to write a command that says 'If.... Then Copy "the cell on the top row of whatever column 'rng.offset(0,k)' happens to be at the moment?" 是否可以编写一条命令“如果...。然后复制”“此时恰好在'rng.offset(0,k)'列的第一行上的单元格”的命令?

It would be easy to write this as another Offset command, but if the column and row of Rng is changing, is it possible to write a command that copies the top row of this? 将其编写为另一个Offset命令会很容易,但是如果Rng的列和行发生变化,是否可以编写一条复制该行顶部的命令?

Thanks in advance, 提前致谢,

最上面一行的单元格是sheet.cells(1,“ k”)–

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

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