|
21组 ID号:jxncfxsf
Sub 选取符合条件的单元格1()
Dim x, y As Long
Dim st As String
For x = 2 To Range("d" & Rows.Count).End(xlUp).Row
If Cells(x, 4).Value > 20 Then
st = st & x & ":"
For y = x + 1 To Range("d" & Rows.Count).End(xlUp).Row
If Cells(y, 4) > 20 Then
x = x + 1
Else: Exit For
End If
Next y
st = st & x & ","
End If
Next x
st = Left(st, Len(st) - 1)
Range(st).Select
End Sub
Sub 选取符合条件的单元格2()
Dim x As Long
Dim rg As Range
For x = 2 To Range("d" & Rows.Count).End(xlUp).Row
If Cells(x, 4) > 20 Then
If rg Is Nothing Then
Set rg = Rows(x)
Else
Set rg = Union(rg, Rows(x))
End If
End If
Next x
rg.Select
End Sub
Sub 选取符合条件的单元格3()
Dim x As Long
Dim rg As Range
For x = 2 To Range("d" & Rows.Count).End(xlUp).Row
If Cells(x, 4) > 20 Then
If rg Is Nothing Then
Set rg = Cells(x, 1).Resize(1, Columns.Count)
Else
Set rg = Union(rg, Cells(x, 1).Resize(1, Columns.Count))
rg.Select
End If
End If
Next x
End Sub |
评分
-
查看全部评分
|