[英]Excel VBA Looping formula to change Range
I've written a code to manipulate data in L9 : DC9
, But now I need to repeat this for L10 : DC10
, L11 : DC11
and etc.. I've tried a For Next
loop replacing the value in the range with Li:DCi
and specifying ( i
) as 9 to 30 but I get an error. 我已经写了一个代码来处理
L9 : DC9
数据,但是现在我需要对L10 : DC10
, L11 : DC11
等重复此操作。我已经尝试了一个For Next
循环,用Li:DCi
替换了范围内的值Li:DCi
并将( i
)指定为9到30,但出现错误。 How can I make a loop for this function? 我如何为此功能循环?
My current version of Excel is 2013 我当前的Excel版本是2013
What you are looking for is a syntax like this 您正在寻找的是这样的语法
Sub LoopRows()
Dim i As Integer
For i = 9 To 30
ActiveSheet.Range("L" & i & ":DC" & i).Interior.Color = RGB(100, 100, 100)
Next i
End Sub
This example just formats the color of the cell in each row. 本示例仅格式化每行中单元格的颜色。 Notice how I use the for-loop to create a looping range selection.
注意我如何使用for循环创建循环范围选择。
我建议使用Range("L9").Resize(21,50).Interior.Color = ..
在一条语句中执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.