如何将其简化为一句话?

时间:2018-04-26 06:37:49

标签: excel-vba vba excel

我想在VBA中简化这个,是否可能?

On Error Resume Next

 [B11] = "=Y11"
 [B12] = "=Y12" 
 [B13] = "=Y13"
 [B14] = "=Y14"
 [B15] = "=Y15"
 [B16] = "=Y16"
 ...

End Sub

2 个答案:

答案 0 :(得分:2)

尝试以下代码:

Range("B11:B16") = "=Y11"

答案 1 :(得分:0)

尝试以下:

for i=11 to 16
    Range("B"& i) = "=Y"& i
next i