|
楼主 |
发表于 2023-2-16 10:23
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub fhxy()
Dim arr, rng As Range
On Error Resume Next
arr = Sheets("数据源").Range("a1").CurrentRegion
Sheet4.Activate
s1 = [b1]: s2 = [b2]
For x = 2 To UBound(arr)
If arr(x, 3) < s2 And arr(x, 3) > s1 Then
With Sheets("database")
If rng Is Nothing Then
Set rng = .Range(.Cells(x, 1), .Cells(x, 10))
Else
Set rng = Union(rng, .Range(.Cells(x, 1), .Cells(x, 10)))
End If
End With
End If
Next x
If Not rng Is Nothing Then
rng.Copy Range("c1")
End If
End Sub应该是要改变量对象 |
|