資料擺放位置請自行調整
Sub ex()
Dim a As Object, X%, Y%
Y = 1
For Each a In Range([a1], [a1].End(4))
For X = a.Row + 1 To [a1].End(4).Row
Cells(Y, 3) = "[" & Format(Cells(a.Row, 1), "0#") & "." & Format(Cells(X, 1), "0#") & "]" '資料放置於欄位(C)
Y = Y + 1
Next
Next
End Sub作者: eric7765 時間: 2021-3-10 21:25
回復 5#dou10801
5選2
Sub ex1()
Dim a As Object, b As Object, X%, Y%
Range([a7], [a7].End(4)).Clear
Y = 7
For Each a In [a1].CurrentRegion.Columns
For Each b In a.Rows
For X = b.Row + 1 To Cells(1, b.Column).End(4).Row
Cells(Y, 1) = "[" & Format(Cells(b.Row, b.Column), "0#") & "." & Format(Cells(X, b.Column), "0#") & "]"
Y = Y + 1
Next
Next
Next
End Sub
5選3
Sub ex2()
Dim a As Object, b As Object, X%, Y%
Range([a7], [a7].End(4)).Clear
Y = 7
For Each a In [a1].CurrentRegion.Columns
For Each b In a.Rows
For X = b.Row + 1 To Cells(1, b.Column).End(4).Row
If X + 1 <= Cells(1, b.Column).End(4).Row Then
Cells(Y, 1) = "[" & Format(Cells(b.Row, b.Column), "0#") & "." & Format(Cells(X, b.Column), "0#") & "." & Format(Cells(X + 1, b.Column), "0#") & "]"
Y = Y + 1
End If
Next
Next
Next
End Sub作者: eric7765 時間: 2021-3-11 10:57
5選2
Sub ex1()
Dim a As Object, b As Object, X%, Y%
[a7].CurrentRegion.ClearContents
Y = 7
For Each a In [a1].CurrentRegion.Columns
For Each b In a.Rows
For X = b.Row + 1 To Cells(1, b.Column).End(4).Row
Cells(Y, b.Column) = "[" & Format(Cells(b.Row, b.Column), "0#") & "." & Format(Cells(X, b.Column), "0#") & "]"
Y = Y + 1
Next
Next
Y = 7
Next
End Sub
5選3
Sub ex2()
Dim a As Object, b As Object, X%, Y%
[a7].CurrentRegion.ClearContents
Y = 7
For Each a In [a1].CurrentRegion.Columns
For Each b In a.Rows
For X = b.Row + 1 To Cells(1, b.Column).End(4).Row
If X + 1 <= Cells(1, b.Column).End(4).Row Then
Cells(Y, b.Column) = "[" & Format(Cells(b.Row, b.Column), "0#") & "." & Format(Cells(X, b.Column), "0#") & "." & Format(Cells(X + 1, b.Column), "0#") & "]"
Y = Y + 1
End If
Next
Next
Y = 7
Next
End Sub作者: dou10801 時間: 2021-3-11 15:22