我正在试图弄清楚如果总取件时间或总交货时间大于0来取决于Sheet2,如何从sheet1中仅提取某些数据。我附上了将要包含的表格和示例数据的图片。我知道如何使用高级过滤器来处理宏,但我不确定如何处理这个宏,因为标题上的页面位于列a的一侧而不是位于顶部。
由于
答案 0 :(得分: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
如果你这样做,你必须将sh1x设置为你要检查的列,并sh2y到你想要粘贴到的行。如果你想自动执行此操作,请将sh1x设置为2,将sh2y设置为2,然后创建一个循环,在每次循环时增加sh1x和sh2y的值(确保在IF之前或之后增加它们的值)。 / p>