exl 有没有查找一组区间数的功能

来源:百度知道 编辑:UC知道 时间:2024/05/14 18:36:00
比如说在一系列数中找到在大于等于4小于8的数

我是假设你的数据在A列,将区间内的数显示在C列
在宏代码框中输入以下代码,运行

Dim a As Integer, c As Integer, x As Integer, e As Integer
a = 1: c = 1: x = 1: e = 1
Dim d(1 To 63356) As Integer
Range("a:a").Select
a = WorksheetFunction.Count(Selection)
Range("a1").Select
For c = 1 To a
If WorksheetFunction.And(Selection <= 8, Selection >= 4) Then
d(e) = ActiveCell.Value
e = e + 1
End If
ActiveCell.Offset(1, 0).Select
Next c
Range("c1").Select
For x = 1 To e - 1
ActiveCell.Value = d(x)
ActiveCell.Offset(1, 0).Select
Next x

两个方法:
1、VBA的

Sub tts()
Dim i%, s%, t&
i = Range("a65536").End(xlUp).Row

For t = 1 To i
If Cells(t, 1) >= 4 And Cells(t, 1) < 8 Then
s = Range("b65536").End(xlUp).Row + 1
Cells(s, 2) = Cells(t, 1).Value
End If

Next

End Sub
2、函数的
你的数据在A列,并且共