excel - 使用多个值从另一个范围中提取多个匹配项
问题描述
我有数据列表(一列有值),我想将其设置为值,以便从另一个范围中提取数据。我知道 Value 只能处理一个单元格,有解决方法吗?
- 第 1 步,在 G 列中设置值的范围
- 步骤 2,在 A 列中查找匹配结果
- 步骤3,将其粘贴到G列到L(有时每个匹配结果会有多行数据,因此步骤1中的值X可能在步骤2中出现多次。)
Sub finddata()
Dim place As Long
Dim FinalRow As Long
Dim i As Integer
Set place = Sheets(1).Range("h2:H10").Value
FinalRow = Sheets(1).Range("A10000").End(xlUp).Row
For i = 2 To FinalRow
If Sheets(1).Cells(i, 1) = place Then
Sheets(1).Range(Cells(i, 1), Cells(i, 5)).Copy
Sheets(1).Range("H100").End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulasAndNumberFormats
End If
Next i
End Sub
好的,这就是我现在使用自动过滤器所达到的程度。现在的问题是它只从获取列表中过滤第一行。换句话说,来自“G2”的值
Sub hamta()
Dim ary As Variant
With Worksheets(1).Cells(1, 1).CurrentRegion
'with true numbers in column A this DOES NOT work
ary = Range("g2:g5").Value
AutoFilter field:=1, Criteria1:=ary, Operator:=xlFilterValues
'with true numbers in column A this DOES work
End With
End Sub
解决方案
推荐阅读
- html - 简单的 CSS 幻灯片卡在最后 3 张图像上
- javascript - 反应 setState 不改变状态
- database - 如何在 Cassandra 中查询范围
- elasticsearch - Elasticsearch - 如何在所有索引和文档中搜索部分单词
- c# - C# Azure AppendBlob AppendBlock 添加大于 4mb 限制的文件
- excel - 如何将一组形状保存为 JPG 图像?
- sql - SQL Server 响应时间增加
- terraform - 从远程状态调用值
- c# - 在 WPF 中使用 DataGrid 更新 SQL 数据库
- java - Spring Boot bean 验证