|
sub题目2的功能是选取A2:C12区域大于0的数字单元格所在的行。我编写的这个程序如果按逐语句运行则可以实现,但是如果直接运行就只选择最后一个符合条件单元格所在的行。麻烦各位高手指点指点看是出错在哪了,谢谢!
Sub 题目2()
Dim x As Integer
Dim y As Integer
Dim rg As Range
For x = 2 To 12 Step 1
For y = 1 To 3 Step 1
If Cells(x, y) > 0 And IsNumeric(Cells(x, y)) Then
Set rg = Cells(x, y)
Set rg = Union(rg, Cells(x, y))
End If
Next y
Next x
rg.EntireRow.Select
End Sub
If rg Is Nothing Then
Set rg = Cells(x, y)
Else
Set rg = Union(rg, Cells(x, y))
End If
|
|