2016-06-21 10 views
-3

トータルピックアップ時間またはトータルデリバリー時間が0より大きい場合、シート1から特定のデータのみを抽出する方法を解明しようとしています。私は、シートの写真とサンプルデータを添付しました。私は、高度なフィルタを使用してマクロを行う方法を知っていますが、ヘッダーのシート上の列の上にあるのではなく、一番上にあるため、これを処理する方法がわかりません。1つのシートから別のシートにデータを抽出する

おかげ

Sheet1

Sheet2

答えて

0
Dim sh1 as Worksheet 
Dim sh2 as Worksheet 
Dim sh1x, sh2y as Ineteger 'You have to set sh1x to the column you want to check & sh2y to the row you want the data to be transfered to 


Set sh1 = ActiveWorkbook.Sheets("Audit") 
Set sh2 = ActiveWorkbook.Sheets("Wait Time") 

If sh1.Cells(20, sh1x).Value > 1 or sh1.Cells(21, sh1x).Value > 1 then 
    sh2.Cells(sh2y, 1) = sh1.Cells(2, sh1x) 
    sh2.Cells(sh2y, 2) = sh1.Cells(3, sh1x) 
    sh2.Cells(sh2y, 3) = sh1.Cells(4, sh1x) 
    sh2.Cells(sh2y, 4) = sh1.Cells(5, sh1x) 
    sh2.Cells(sh2y, 5) = sh1.Cells(6, sh1x) 
    sh2.Cells(sh2y, 6) = sh1.Cells(7, sh1x) 
    sh2.Cells(sh2y, 7) = sh1.Cells(20, sh1x) 
    sh2.Cells(sh2y, 8) = sh1.Cells(21, sh1x) 
End If 

あなたはこのようにそれを行う場合は、あなたがそれをペーストしたい行にチェックして、sh2yしたい列にsh1xを設定する必要がありますに。これを自動的に行うには、sh1xを2に、sh2yを2に設定し、ループするたびにsh1xとsh2yの値を増やすループを作成します(IFの前または後に値を必ず増やしてください)。

関連する問題