早上好, 我需要查找工作表 1 的 J 和 K 列中的值,看看该行中的任一列是否为 <3.5. If they are, I need to Copy that line to a sheet. This would repeat for each line on a spreadsheet. Then on Sheet 2 find the same starting mile marker in Column C and copy the next 10 lines below the condition found on sheet 1.
即:
在这种情况下,我希望看到以下内容
表 3 将列出所有找到的实例,而无需跳行
这将解决第一个要求:
Sub test()
Dim row As Long
Dim sht As Worksheet
Dim sht2 As Worksheet
Dim LastRow As Long
Dim sheet2Row As Long
Set sht = Worksheets("Sheet1")
Set sht2 = Worksheets("Sheet2")
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "J").End(xlUp).row
sheet2Row = 1
For row = 2 To LastRow
If sht.Cells(row, 10) > 3.5 Or sht.Cells(row, 10) > 3.5 Then
sht.Range(row & ":" & row).Copy sht2.Range(sheet2Row & ":" & sheet2Row)
sheet2Row = sheet2Row + 1
End If
Next row
End Sub
但是,我不明白您问题的第二部分“然后在第 2 页上,在 C 列中找到相同的起始英里标记,并复制第 1 页上找到的条件下方的接下来 10 行。”