|
本帖最后由 Excel学徒123 于 2016-9-8 08:57 编辑
代码解决,具体看附件,代码运行之后记得在结果列点成自动换行
- Sub test()
- Dim arrSrc, arrRst()
- Dim irow%, iCol%, iCnt%
- Dim Ends%
- Dim strText$
- Ends = Cells(Rows.Count, 1).End(3).Row
- arrSrc = Range("a2:e" & Ends).Value
- ReDim arrRst(1 To UBound(arrSrc), 1 To 1)
- For irow = 1 To UBound(arrSrc)
- For iCol = 1 To UBound(arrSrc, 2)
- iCnt = iCnt + 1
- If Len(arrSrc(irow, iCol)) > 0 Then
- strText = strText & iCnt & "、" & arrSrc(irow, iCol) & Chr(10)
- End If
- Next
- If iCnt > 0 Then
- arrRst(irow, 1) = Left(strText, Len(strText) - 1)
- iCnt = 0
- strText = ""
- End If
- Next
- Range("f2").Resize(UBound(arrRst)) = arrRst
- End Sub
复制代码 |
评分
-
查看全部评分
|