|
- Public Sub wang_way()
- 'vx
- '日期 2022-01-08
- Dim Wb As Workbook
- Dim Sht As Worksheet
- Dim Rng As Range
- Dim arr, brr()
- Set Wb = Application.ThisWorkbook
- Set Sht = Wb.Worksheets(1)
- With Sht
- endrow = .Cells(.Rows.Count, 1).End(xlUp).Row
- Set Rng = .Range("A2:D" & endrow)
- arr = Rng.Value
- ReDim brr(1 To (UBound(arr) - 1) * (UBound(arr, 2) - 1), 1 To 3)
- n = 0
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- n = n + 1
- brr(n, 1) = arr(i, 1)
- brr(n, 2) = arr(i, j)
- brr(n, 3) = arr(1, j)
- Next j
- Next i
-
- endcol = .Cells(1, .Columns.Count).End(xlToLeft).Column + 2
- Set Rng = .Cells(2, endcol)
- Rng.Resize(UBound(brr), UBound(brr, 2)).Value = brr
-
- End With
-
- Set Wb = Nothing
- Set Sht = Nothing
- Set Rng = Nothing
- End Sub
复制代码 |
|