|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 三列表转横竖表()
- Dim Arr, DicXm As Object, DicFx As Object, i&, j&, Brr()
- Set DicXm = CreateObject("Scripting.Dictionary")
- Set DicFx = CreateObject("Scripting.Dictionary")
- With Worksheets("Sheet1")
- Arr = .Range(.Cells(2, "C"), .Cells(Rows.Count, "A").End(xlUp))
- End With
- For i = 1 To UBound(Arr)
- If Not DicFx.exists(Arr(i, 3)) Then DicFx(Arr(i, 3)) = DicFx.Count + 1
- If Not DicXm.exists(Arr(i, 1)) Then DicXm(Arr(i, 1)) = DicXm.Count + 1
- Next i
- With Worksheets("Sheet1")
- .[F1].Offset(0, 1).Resize(1, DicFx.Count) = DicFx.keys
- .[F1].Offset(1, 0).Resize(DicXm.Count, 1) = Application.WorksheetFunction.Transpose(DicXm.keys)
- ReDim Brr(1 To DicXm.Count, 1 To DicFx.Count)
- For i = 1 To UBound(Arr)
- Brr(DicXm(Arr(i, 1)), DicFx(Arr(i, 3))) = Arr(i, 2)
- Next i
- .[F1].Offset(1, 1).Resize(DicXm.Count, DicFx.Count) = Brr
- End With
- Set DicFx = Nothing
- Set DicXm = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|