2017-08-30 85 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