2017-07-31 10 views
0

以下の表があります(入力)。 リスト出力を取得する方法を探しています(画像参照)。複数の配列を含むExcelテーブル

Table Input/Output

+1

お試しください。 –

+0

この例では問題がよく定義されていません。あなたの例では、30/07/2017の3行の出力しか表示しないので、日付の項目の複数の出現は、出現ごとの行ではなく出力行を1つだけ生成しなければなりません(@ Mrigは仮定した)。それは最初の2つの入力列に切り捨てるのではなく、あなたの例に完全な出力表を含めた方が明らかでしょう。あなたは 'VBA'であなたの質問にタグを付けていないので、あなたはVBAを避ける解決策を探していますか? – DMM

答えて

0

助けるべき次のとおりです。

Option Explicit 

Sub Demo() 
    Application.ScreenUpdating = False 
    Application.Calculation = xlCalculationManual 

    Dim lastRow As Long, lastCol As Long, rowIndex As Long, colIndex As Long 
    Dim i As Long, currRow As Long 
    Dim ws As Worksheet, arr 

    Set ws = ThisWorkbook.Worksheets("Sheet1")  'change Sheet1 to your working sheet 

    With ws 
     lastRow = .Cells(.Rows.Count, 1).End(xlUp).Row 'get last row in column A 
     lastCol = Cells(3, Columns.Count).End(xlToLeft).Column 'get last column in row 3 
     currRow = 3  'output will be displayed from row 3 

     For rowIndex = 4 To lastRow 'loop through all rows in input starting with row 4 
      For colIndex = 2 To lastCol 'loop trough all columns in input starting form column 2 
       arr = Split(.Cells(rowIndex, colIndex).Value, ",") 'put comma separated value of a cell in array 
       For i = LBound(arr) To UBound(arr) 'loop through array item 
        .Range("I" & currRow).Value = .Range("A" & rowIndex).Value 'display name 
        .Range("J" & currRow).Value = .Cells(3, colIndex) 'display date 
        .Range("K" & currRow).Value = Trim(arr(i)) 'display cell value 
        currRow = currRow + 1  'increment crrRow value by 1 
       Next i 
      Next colIndex 
     Next rowIndex 
    End With 

    Application.ScreenUpdating = True 
    Application.Calculation = xlCalculationAutomatic 
End Sub 

は参照用の画像を参照してください。

enter image description here

関連する問題