2017-08-30 54 views
0

我想在一列中对多个列中的一些条目进行排序和筛选。 表看起来是这样的:在Excel中查找多个实例

Day Product.ID Quantity Time Product.ID Quantity Time Product.ID Quantity Time 
    1/1/17 9987/7  2500  8 11774  500  12 447/77  1400  4 
    2/1/17 9987/7  2350  8 2248/5  600  11 9987/7  1400  4 
    3/1/17 2248/5  3500  7 11774  650  12 447/77  1400  4 
    6/1/17 447/77  5500  8 11774  550  10 447/77  1400  4 
    7/1/17 9987/7  2000  6 2248/5  500  12 11774  1400  4 

我想生成一个“查询”在那里我可以以类似的方式报告:

Product.ID: 9987/7 (drop down menu) 
    Day Quantity Time 
    1/1/17 2500  8 
    2/1/17 2350  8 
    2/1/17 1400  4 
    7/1/17 2000  6 

从那里我可以推断我的所有数据和结论。我知道如何检查单个列,并且其他单元格是INDEXVLOOKUP,但我无法弄清楚如何以这种方式执行此操作。 我不能将数据转置到单个列上,因为它们来自已编译的工作表,并且每个机器都有生产数据。

谢谢大家

+0

向我们展示你做了什么,并在那里你遇到了问题。为什么数据源会影响您是否可以将新工作簿中的数据重新格式化为一组列? –

+0

这是我用来从第一列获取数据的基本公式 = IF(ISERROR(INDEX($ A $ 1:$ B $ 8,SMALL(IF($ A $ 1:$ A $ 8 = $ E $ 1, ROW($ A $ 1:$ A $ 8)),ROW(1:1)),2)), “”,INDEX($ A $ 1:$ B $ 8 SMALL(IF($ A $ 1:$ A $ 8 = $ 1美元,行($ A $ 1:$ A $ 8)),行(1:1)),2)) 我当然更改了参考表和输出(这个来自http:// eimagine .com/how-to-return-multiple-match-values-in-excel-using-index-match-or -vlookup /) 我会粘贴我实际使用的一个,但Excel是意大利语,所以它会理解或翻译一团糟。 – Khellendros

+0

数据无法在单个列中重新格式化,因为sheet1将每天使用新数据进行更新,而不是我必需的。对于我所处的工作环境(低IT技能),甚至要求他们填写数字表格已经足够困难 – Khellendros

回答

0

我试图重新您的电子表格 并把结果在细胞L.

我写的,可能作为参考来解决问题一些快速的VBA代码。您可以制作一个按钮来触发过滤器功能并让它填充。

enter image description here

Sub filter(): 
Dim i, j, k As Integer 
Dim product_id As String 
Dim column_len, row_len As Integer 

'clearing content from previous entry 
Sheets("Sheet1").Range("L3:N6").ClearContents 

'Determining variable for row and columns 
product_id = Sheets("Sheet1").Range("M2").Value 
column_len = Cells.CurrentRegion.Columns.Count 
row_len = Cells.CurrentRegion.Rows.Count 
k = 3 

'for loop through the columns and row to find the product_id and populate 
'the results box with Date, Product.ID and Quantity 

For i = 1 To column_len 
    If (Sheets("Sheet1").Cells(1, i).Value = "Product.ID") Then 
     For j = 1 To row_len 
      If (Sheets("Sheet1").Cells(j, i).Value = product_id) Then 
       Sheets("Sheet1").Cells(k, 12).Value = Sheets("Sheet1").Cells(j, 1).Value 
       Sheets("Sheet1").Cells(k, 12 + 1).Value = Sheets("Sheet1").Cells(j, i).Value 
       Sheets("Sheet1").Cells(k, 12 + 2).Value = Sheets("Sheet1").Cells(j, i + 1).Value 
       k = k + 1 
      End If 
     Next j 
    End If 
Next i 

End Sub 
+0

非常感谢。我会尝试并实施它。 我对VBA并不是非常熟悉,我仍然会寻找一个类似的解决方案,只是使用excel代码,但作为临时解决方案,这可能是最好的。 – Khellendros

+0

我已经设法查看你的代码,并且有一个问题,那就是日期。 (“Sheet1”)。Cells(k,12).Value = Sheets(“Sheet1”)。Cells(j,i - 1).Value' should read'Sheets(“Sheet1”)。单元格(k,12)。值=单元格(“Sheet1”)。单元格(j,1)。值' 此外,在这种情况下,最好先检查每行,然后每列,但是快速调整。 谢谢你的时间 – Khellendros

+0

是的,你是对的。我错过了那一个。我记得想过但忘记在代码中实现它。我会编辑我的答案。 我使用的是VBA,因为我认为excel没有设计用于处理那种数据结构而不改变格式或将报告复制到另一个表格中并对其进行预处理。但也许这只是我有限的Excel知识。 – Windalfin