首页 > 解决方案 > VBA 将数据分离和转置成行

问题描述

我一直在试图弄清楚如何使用以下格式将工作表上的两列数据分成行。

从:

图像1

至:

img2

我能够从另一个帖子(下面链接)中找出其中的一部分(分离和转置 B 列中的名称),但我不知道如何复制 A 列中的数据

Sub Vertical()
Dim i As Long, st As String
i = 1
Dim startP As Range
For Each r In Selection
    If i = 1 Then
        st = r.Text
        i = 2
    Else
        st = st & "," & r.Text
    End If
Next r

Set startP = Selection(1, 2)
ary = Split(st, ",")
i = 1
For Each a In ary
    startP(i, 1).Value = a
    i = i + 1
Next a  
End Sub

当然,实际数据是我们系统中的一长串工作区和工作它们的员工。我只是不能在这里发布。

先感谢您!!!

标签: excelvbadelimiterexcel-2013transpose

解决方案


推荐阅读