|
补交作业来罗。
Option Explicit
Sub RAGNE方法2()
'这个是我在群内学友提醒用拼装字符方法的提示下自己想出来的,又根据校长的第三种方法改编的
Dim x As Integer
Dim y As Integer, k As Integer
Dim dz As String
y = 4
dz = ""
For x = 2 To 24
k = x
If Cells(x, y).Value > 20 Then
Do While Cells(x, y).Value > 20
x = x + 1
Loop
If dz = "" Then
dz = k & ":" & x - 1 & ","
Else
dz = dz & k & ":" & x - 1 & ","
End If
End If
Next x
dz = Left(dz, Len(dz) - 1)
Range(dz).Select
' Cells(1, 6).Value = dz
End Sub
Sub RAGNE方法()
'这个是我在群内学友提醒用拼装字符方法的提示下自己想出来的
Dim x As Integer
Dim y As Integer
Dim dz As String
y = 4
dz = ""
For x = 2 To 24
If Cells(x, y).Value > 20 Then
dz = dz & x & ":" & x & ","
End If
Next x
dz = Left(dz, Len(dz) - 1)
Range(dz).Select
' Cells(1, 6).Value = dz
End Sub
Sub union2方法()
'这个是抄来的,根据校长的第三种方法修改了
Dim x As Integer, k As Integer
Dim rg As Range
For x = 2 To Range("d" & Rows.Count).End(xlUp).Row
k = x
If Cells(x, 4) > 20 Then
Do While Cells(x, 4).Value > 20
x = x + 1
If rg Is Nothing Then
Set rg = Rows(k & ":" & x - 1)
Else
Set rg = Union(rg, Rows(k & ":" & x - 1))
End If
Loop
End If
Next x
rg.Select
End Sub
Sub union1方法()
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
|
|