0
我試圖生成在Excel組合id_users他們有我用這個示例代碼relation..so來給了我這樣的結果:換行VBA代碼
輸入是一個透視表:
' id_row id_users
10 1
2
3
66 4
11
這是我的輸出
'source target label
1 2 10
1 3 10
2 3 10
4 11 66
但它給了我這樣的結果:
'source target label
1 2 10
1 3 10
2 1 10
2 3 10
3 1 10
3 2 10
4 11 66
11 4 66
因爲你看到我不想顯示交換行也沒關係,如果它顯示重複的行..但我不想顯示交換的數據.. like:1 2和2 1 它doesn這不意味着任何東西只是一個重複的信息,如:一個與B有一個關係,然後你看到B與一個有關係..它只是一個信息的重複,首先我有它... 在我的代碼是這表明SQ USER_1這不等於在SQQ user_2數據的數據數組,但我也想表明,不會在透水 平方米USER_1稱爲數據:
'
'get the combinationsin the pivot table for this topic
sq = Range(rTopic, rTopic.End(xlDown).Offset(-1)).Offset(, 1).Resize(, 2).SpecialCells(2, 1).Value
'get the unique combinations of persons
sUniq = " "
For lUser_2 = 1 To UBound(sq, 1)
If InStr(sUniq, " " & sq(lUser_2, 2) & " ") = 0 Then
sUniq = sUniq & sq(lUser_2, 2) & " "
End If
Next
sqq = Split(Trim(sUniq))
'loop over user id's and generate combinations
For lUser_1 = 1 To UBound(sq, 1)
For lUser_2 = 0 To UBound(sqq)
If sq(lUser_1, 2) & "" <> sqq(lUser_2) Then
'we found a new combination, output to screen
Range(sStartingCellOutput).Offset(lRowOffset, lColOffset).Resize(1, 3).Value = Array(sq(lUser_1, 2), sqq(lUser_2), rTopic.Value)
'increment the counter
lRowOffset = lRowOffset + 1
If lRowOffset >= Rows.count Then
lRowOffset = 0
lColOffset = lColOffset + 4
End If
End If
Next
Next
我editted它解釋得我code..just PLZ我需要一個samll的幫助?如果我的Q是不明確的只是對我評論...感謝
感謝..我添加it..but它仍然是相同的..:S –