|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Test()
- Dim shSource As Worksheet
- Dim arrSource As Variant, lngRow As Long, lngCount As Long
- Dim strNum(1 To 3) As String, strTemp As String, strFind As String
- Dim strSplit_A() As String, strSplit_B() As String, strSplit_C() As String
- Dim strResult() As String
- Dim lngA As Long, lngB As Long, lngC As Long
-
- Set shSource = Sheets("Sheet3")
-
- arrSource = shSource.Range("B2:B4")
- lngCount = 1
- For lngRow = 1 To 3
- strTemp = arrSource(lngRow, 1)
- strTemp = Replace(strTemp, ",", Space(1))
- strTemp = Trim(strTemp)
- strNum(lngRow) = strTemp
- lngCount = lngCount * (UBound(Split(strTemp, Space(1))) + 1)
- Next
-
-
- ReDim strResult(1 To lngCount, 1 To 1) As String
- lngCount = 1
- strTemp = strNum(1)
- strSplit_A = Split(strTemp)
- For lngA = LBound(strSplit_A) To UBound(strSplit_A)
- strTemp = Space(1) & strNum(2) & Space(1)
- strFind = Space(1) & strSplit_A(lngA) & Space(1)
- strTemp = Replace(strTemp, strFind, Space(1))
- strTemp = Trim(strTemp)
- strSplit_B = Split(strTemp)
- For lngB = LBound(strSplit_B) To UBound(strSplit_B)
- strTemp = Space(1) & strNum(3) & Space(1)
- strFind = Space(1) & strSplit_A(lngA) & Space(1)
- strTemp = Replace(strTemp, strFind, Space(1))
- strFind = Space(1) & strSplit_B(lngB) & Space(1)
- strTemp = Replace(strTemp, strFind, Space(1))
- strTemp = Trim(strTemp)
- strSplit_C = Split(strTemp)
- For lngC = LBound(strSplit_C) To UBound(strSplit_C)
- strTemp = strSplit_A(lngA) & "," & strSplit_B(lngB) & "," & strSplit_C(lngC)
- strResult(lngCount, 1) = strTemp
- lngCount = lngCount + 1
- Next
- Next
- Next
-
- shSource.Range("D2").Resize(UBound(strResult), 1) = strResult
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|