沒測試
- Sub Generate()
- Dim i As Integer, j As Integer
- Dim x As Integer
- Dim z&, Sht1Arr, Sht2Brr, a
- x = 9
- With Sheet1
- z = .Range("G65536").End(xlUp).Row
- Sht1Arr = .Range("e1:z" & z).Value
- End With
- a = Array(3, 4, 1, 2, 12, 14, 16, 15, 20, 22)
- Sht2Brr = Worksheets("Sheet2").Range("a1:j" & z).Value
- With Worksheets("Sheet2").Range("A9:K9999")
- .ClearContents
- .Interior.Color = xlNone
- .Font.Color = RGB(0, 0, 0)
- For i = 3 To z
- If .Range("B5").Value = Sht1Arr(i, 3) Then
- For j = 0 To UBound(a)
- Sht2Brr(x, j + 1) = Sht1Arr(i, a(j))
- Next
- Sht2Brr(x, j) = Sht2Brr(x, j) + Worksheets("sheet1").Range("AE" & i).Value
- x = x + 1
- End If
- Next i
- .Range("a1").Resize(i - 1, 10) = Sht2Brr
- End With
- End Sub
复制代码 |