Separating one column into two column excel formatting

%3CLINGO-SUB%20id%3D%22lingo-sub-2605373%22%20slang%3D%22en-US%22%3ESeparating%20one%20column%20into%20two%20column%20excel%20formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2605373%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%20anyone%20is%20able%20to%20help%20me%20whether%20how%20can%20I%20separating%20the%20numbers%20into%20the%20left%20column%20and%20words%20will%20be%20in%20the%20right%20column.%20I%20had%20attached%20an%20excel%20file%20with%20a%20single%20column.%20My%20output%20will%20be%20shown%20on%20the%20right%20side%20of%20excel%20with%202%20columns%20and%20words%2Fnumbers%20separated.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2605373%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2605511%22%20slang%3D%22en-US%22%3ERe%3A%20Separating%20one%20column%20into%20two%20column%20excel%20formatting%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2605511%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1119338%22%20target%3D%22_blank%22%3E%40evilgreenred%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ERun%20the%20following%20macro.%20You%20can%20change%20the%20output%20column%20by%20changing%20the%20value%20of%20TargetCol%20in%20the%20code.%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3Eub%20SplitData()%0A%20%20%20%20Const%20SourceCol%20%3D%202%20'%20column%20B%0A%20%20%20%20Const%20TargetCol%20%3D%204%20'%20column%20D%0A%20%20%20%20Dim%20SourceRow%20As%20Long%0A%20%20%20%20Dim%20LastRow%20As%20Long%0A%20%20%20%20Dim%20TargetRow%20As%20Long%0A%20%20%20%20Dim%20LineNumber%20As%20Long%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20TargetRow%20%3D%201%0A%20%20%20%20Cells(TargetRow%2C%20TargetCol).Resize(1%2C%202).Value%20%3D%20Array(%22Number%22%2C%20%22Solution%22)%0A%20%20%20%20LastRow%20%3D%20Cells(Rows.Count%2C%20SourceCol).End(xlUp).Row%0A%20%20%20%20For%20SourceRow%20%3D%202%20To%20LastRow%0A%20%20%20%20%20%20%20%20If%20IsNumeric(Cells(SourceRow%2C%20SourceCol).Value)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20LineNumber%20%3D%20Cells(SourceRow%2C%20SourceCol).Value%0A%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20TargetRow%20%3D%20TargetRow%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20Cells(TargetRow%2C%20TargetCol).Resize(1%2C%202).Value%20%3D%20Array(LineNumber%2C%20Cells(SourceRow%2C%20SourceCol).Value)%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20SourceRow%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi, anyone is able to help me whether how can I separating the numbers into the left column and words will be in the right column. I had attached an excel file with a single column. My output will be shown on the right side of excel with 2 columns and words/numbers separated. 

1 Reply

@evilgreenred 

Run the following macro. You can change the output column by changing the value of TargetCol in the code.

 

Sub SplitData()
    Const SourceCol = 2 ' column B
    Const TargetCol = 4 ' column D
    Dim SourceRow As Long
    Dim LastRow As Long
    Dim TargetRow As Long
    Dim LineNumber As Long
    Application.ScreenUpdating = False
    TargetRow = 1
    Cells(TargetRow, TargetCol).Resize(1, 2).Value = Array("Number", "Solution")
    LastRow = Cells(Rows.Count, SourceCol).End(xlUp).Row
    For SourceRow = 2 To LastRow
        If IsNumeric(Cells(SourceRow, SourceCol).Value) Then
            LineNumber = Cells(SourceRow, SourceCol).Value
        Else
            TargetRow = TargetRow + 1
            Cells(TargetRow, TargetCol).Resize(1, 2).Value = Array(LineNumber, Cells(SourceRow, SourceCol).Value)
        End If
    Next SourceRow
    Application.ScreenUpdating = True
End Sub