excel,如何实现A列的数据多对一B列中的数据,按照B列的数据,重复循环至B列所有的数值结束时为止? 100
本来想给你做成公式,但无奈有些知识实在是不会,就只做成了过程,你只需要修改list_A、list_B、rowNum、columnNum,详见以下代码:
Sub createList()
Dim list_A As String
Dim list_B As String
Dim rowNum As Integer
Dim columnNum As Integer
Dim list_left() As String
Dim list_right() As String
Dim i As Integer
Dim j As Integer
'------要修改的变量-----------------
'要形成列表的两个字符串
list_A = "13458"
list_B = "AVCKM"
'放置列表的行号
rowNum = 1
'放置列表的列号
columnNum = 1
'-----------------------------------
' 拆分list_a
ReDim list_left(0 To Len(list_A) - 1)
For i = 0 To Len(list_A) - 1
list_left(i) = Mid(list_A, i + 1, 1)
Next
' 拆分list_b
ReDim list_right(0 To Len(list_B) - 1)
For i = 0 To Len(list_B) - 1
list_right(i) = Mid(list_B, i + 1, 1)
Next
' 通过双层循环来放置数据
For i = 0 To UBound(list_left)
For j = 0 To UBound(list_right)
Cells(rowNum + i * (UBound(list_right) + 1) + j, columnNum) = list_left(i)
Cells(rowNum + i * (UBound(list_right) + 1) + j, columnNum + 1) = list_right(j)
Next
Next
End Sub