Created
July 13, 2017 10:37
-
-
Save ndthanh/7ba9081b27a3edbd20c6112458ef6447 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub SplitAll() | |
Dim xRg As Range | |
Dim xRg1 As Range | |
Dim xCell As Range | |
Dim I As Long | |
Dim xAddress As String | |
Dim xUpdate As Boolean | |
Dim xRet As Variant | |
On Error Resume Next | |
xAddress = Application.ActiveWindow.RangeSelection.Address | |
Set xRg = Application.InputBox("Please select a range", "Kutools for Excel", xAddress, , , , , 8) | |
Set xRg = Application.Intersect(xRg, xRg.Worksheet.UsedRange) | |
If xRg Is Nothing Then Exit Sub | |
If xRg.Columns.Count > 1 Then | |
MsgBox "You can't select multiple columns", , "Hoc Excel Online" | |
Exit Sub | |
End If | |
Set xRg1 = Application.InputBox("Split to (single cell):", "Kutools for Excel", , , , , , 8) | |
Set xRg1 = xRg1.Range("A1") | |
If xRg1 Is Nothing Then Exit Sub | |
xUpdate = Application.ScreenUpdating | |
Application.ScreenUpdating = False | |
For Each xCell In xRg | |
xRet = Split(xCell.Value, ",") | |
xRg1.Worksheet.Range(xRg1.Offset(I, 0), xRg1.Offset(I + UBound(xRet, 1), 0)) = Application.WorksheetFunction.Transpose(xRet) | |
I = I + UBound(xRet, 1) + 1 | |
Next | |
Application.ScreenUpdating = xUpdate | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment