0

我试图划分每一行直到最后一行,但我被困在只除以第 2 行的一行。我正在考虑使用这个

Dim LastRow As Range

LastRow = Range("A" & Rows.Count).End(xlUp).Row

但是我对如何使用该范围的知识非常有限。

请分享您的想法..谢谢!:)

我的代码如下:

Sub test1()


For Each c In Range("AL2:AS2 , BC2 ")
c.Value = c.Value / 1000
Next c

结束子

4

1 回答 1

1

您可以通过构建范围字符串来构建范围,如下所示:

Range("AL2:AS" & LastRow & ", BC2:BC" & LastRow)

注意.RowRange 的属性返回的Long是行号,所以你必须声明:

 Dim LastRow As Long

最后这给出了:

Sub test2()

 Dim LastRow As Long
 Dim myCell As Range

 LastRow = Range("A" & Rows.Count).End(xlUp).Row

 For Each myCell In Range("AL2:AS" & LastRow & ", BC2:BC" & LastRow)
  myCell.Value = myCell.Value / 1000
 Next myCell
End Sub
于 2013-09-06T06:12:45.437 回答