我得到了一个导出的电子表格,该表格具有一个单元格中的数据,并用“ ALT + ENTER”分隔。我希望此数据垂直在每一行上,而不是在单个单元格中。
我试图通过“ CTRL + J”将它们分隔成列。我认为这可能会更容易垂直列出(逐行)。您可以看到我要去的地方
我尝试了一些在网上找到的VBA,但我对此一无所知。如果我想找出解决这个问题的VBA解决方案,那会花我更长的时间,因为我不太了解。
我尝试过:
Sub vertsplit()
Dim xRg As Range
Dim xOutRg As Range
Dim xCell As Range
Dim xTxt As String
Dim xStr As String
Dim xOutArr As Variant
On Error Resume Next
xTxt = ActiveWindow.RangeSelection.Address
Set xRg = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
Set xOutRg = Application.InputBox("please select output cell:", "Kutools for Excel", , , , , , 8)
If xOutRg Is Nothing Then Exit Sub
For Each xCell In xRg
If xStr = "" Then
xStr = xCell.Value
Else
xStr = xStr & "," & xCell.Value
End If
Next
xOutArr = VBA.Split(xStr, ",")
xOutRg.Range("A1").Resize(UBound(xOutArr) + 1, 1) = Application.WorksheetFunction.Transpose(xOutArr)
End Sub
我用逗号替换了“ ALT + ENTERS”,然后尝试了上面的代码,但是它不适用于多个单元格。