我有一个jira-export文件,需要在1NF中获取它才能使用pivot功能。
数据是这样的:
|----|--------|---------------|
| A | B | C |
|----|--------|---------------|
| 1 | BlaBla | C1 |
|----|--------|---------------|
| 2 | FooFoo | C1,C2,C3 |
|----|--------|---------------|
| 3 | LaLa | C3 |
|----|--------|---------------|
我需要这种形式的数据:
|----|--------|---------------|
| A | B | C |
|----|--------|---------------|
| 1 | BlaBla | C1 |
|----|--------|---------------|
| 2 | FooFoo | C1 |
|----|--------|---------------|
| 2 | FooFoo | C2 |
|----|--------|---------------|
| 2 | FooFoo | C3 |
|----|--------|---------------|
| 3 | LaLa | C3 |
|----|--------|---------------|
基本上,如果有多个条目,C列中的数据必须循环并复制/粘贴。
任何想法?
Sub CopyData()
Dim xrow As Long
Dim cCell As Variant
Dim strArray() As String
Dim iCount As Integer
xrow = 1
Do while(Cells(xrow,"A") <> "")
cCell = Cells(xrow,"C") 'get the value in column C
strArray = Split(cCell,",") 'put the value(s) in an array (delimiter ",")
iCount = UBound(strArray) - LBound(strArray)
If iCount > 0 Then
*??????* 'copy the row
*??????* 'paste it below or at the end of the data-set with the different values in column C
*??????* 'remove the row with the ","
End If
xrow = xrow + 1
Loop
End Sub
亲切的问候