Private Sub CommandButton1_Click()Dim lenth As Long
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim date1 As String
Dim voucher1 As String
Dim label1 As Integer
Dim label2 As Integer
k = 2lenth = Worksheets("原始数据2").[A65535].End(xlUp).Row - 1
For i = 1 To lenth
date1 = Worksheets("原始数据2").Cells(i + 1, 1).Value
voucher1 = Worksheets("原始数据2").Cells(i + 1, 2).Value
On Error Resume Next
label1 = Application.WorksheetFunction.Match(date1, Worksheets("原始数据1").Columns("A"), 0)
label2 = Application.WorksheetFunction.Match(voucher1, Worksheets("原始数据1").Columns("B"), 0)
While Worksheets("原始数据1").Cells(label1, 2) <> voucher1
label1 = label1 + 1
Wend
While Worksheets("原始数据1").Cells(label1, 2) = voucher1
For j = 1 To 10
Worksheets("处理1").Cells(k, j).Value = Worksheets("原始数据1").Cells(label1, j)
Next
k = k + 1
label1 = label1 + 1
Wend
Next
End Sub