从列中将类别提取到具有新类别的重复行中

我有一张桌子,看起来像这样:

Group | Name | Comment | Tag 1 | Tag 2 | Tag 3 ------------------------------------------------------------------- gr1 Joe We are... SYSTEM SUGGESTION PAINPOINT gr1 Joe I want... PROCESS ATTITUDE 

我需要运行一个基本上生成这个macros的macros(我使用Excel 2007)

 Group | Name | Comment | Tag 1 | Tag 2 | Tag 3 ------------------------------------------------------------------- gr1 Joe We are... SYSTEM gr1 Joe We are... SUGGESTION gr1 Joe We are... PAINPOINT gr1 Joe I want... PROCESS gr1 Joe I want... ATTITUDE 

所以所有的标签都会得到重复的数据,但它们自己的行 这使我现在可以对信息进行sorting和转换。 我目前不擅长VBA,希望能对这个问题有所帮助。

我希望这是清楚的。

如果你真的需要把它作为vba代码在这里是可能的解决scheme之一:(子程序内的一些额外的意见) 试过和testing

 Sub Solution() 'Select cell with 'Group' title 'Result passed to 10th column to the right 'Macro doesn't care of headers of result table Dim KOM As Range Dim partGNC As Variant Dim partTAG As Variant Dim resRow As Long resRow = ActiveCell.Row + 1 For Each KOM In Range(ActiveCell.Offset(1, 0), ActiveCell.End(xlDown)) partGNC = KOM.Resize(1, 3) partTAG = Range(KOM.Offset(0, 3), KOM.End(xlToRight)) If KOM.Offset(0, 3).Address = KOM.End(xlToRight).Address Then Cells(resRow, KOM.Column + 10).Resize(1, 3) = partGNC Cells(resRow, KOM.Column + 13) = partTAG resRow = resRow + 1 Else Cells(resRow, KOM.Column + 10).Resize(UBound(partTAG, 2), 3) = partGNC Cells(resRow, KOM.Column + 13).Resize(UBound(partTAG, 2), 1) = Application.Transpose(partTAG) resRow = resRow + UBound(partTAG, 2) End If Next End Sub