+ Reply to Thread
Results 1 to 4 of 4

How to arrange the unformatted text in table format

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-08-2020
    Location
    MUMBAI
    MS-Off Ver
    MS Office 2007 (in 2024)
    Posts
    264

    How to arrange the unformatted text in table format

    I have to deal with unformatted text files which contains transactions. I am attaching here sample of this text file in Sheet1 which contains many data which I don’t need. I have manually arranged data of this unformatted text file data in the manner I need in Sheet2. Kindly provide the solution to arrange this data.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: How to arrange the unformatted text in table format

    Try to paste the data from unformatted text to wordpad. From Wordpad copy and paste it worksheet and upload that file.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  3. #3
    Forum Contributor
    Join Date
    04-08-2020
    Location
    MUMBAI
    MS-Off Ver
    MS Office 2007 (in 2024)
    Posts
    264

    Re: How to arrange the unformatted text in table format

    new excel file attached which contains data pasted from wordpad file
    Attached Files Attached Files
    Last edited by KRIXXXX; 01-15-2022 at 12:12 AM.

  4. #4
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: How to arrange the unformatted text in table format

    Code for macro
    Sub RearrangeData()
    Dim Lr As Long, T As Long, X As Long
    Dim A, D
    
    Lr = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
    ReDim B(1 To Lr)
    ReDim C(1 To Lr)
    
    With Sheets("Sheet1")
    A = .Range("A1:A" & Lr)
    
    For T = 1 To Lr
    If Left(A(T, 1), 1) <> "-" And Mid(A(T, 1), 3, 1) = "-" Then
    X = X + 1
    B(X) = A(T, 1)
    If InStr(1, B(X), "/") = 0 And Not IsNumeric(Mid(B(X), 10, 1)) Then B(X) = Left(B(X), 8) & " " & "0" & " " & "0" & " " & Mid(B(X), 40)
    
    B(X) = Replace(B(X), WorksheetFunction.Rept(" ", 40), " " & "0" & " " & "0" & " ")
    
    B(X) = Replace(B(X), WorksheetFunction.Rept(" ", 12), " " & "0" & " ")
    
    If Left(A(T + 2, 1), 1) <> "" Then C(X) = Trim(A(T + 2, 1))
    End If
    Next T
    End With
    
    With Sheets("Sheet3").Range("A2:A" & X + 1)
    .CurrentRegion.Clear
    .Value = WorksheetFunction.Transpose(B)
    .TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
            TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, _
            Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
            :=Array(Array(1, 2), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1)), _
            TrailingMinusNumbers:=True
    .Offset(0, 7).Formula = "=DATE(1*(""20""&MID(A2" & ",7,2)),1*" & "MID(A2" & ",4,2),1*" & "MID(A2" & ",1,2))"
    .Offset(0, 7).Value = .Offset(0, 7).Value
    .Offset(0, 7).Copy Sheets("Sheet3").Range("A2")
    .Offset(0, 7).Value = ""
    End With
    
    T = 0
    With Sheets("Sheet3")
    D = .Range("B2:B" & X + 1)
    
    For T = 2 To UBound(D, 1)
    D(T, 1) = D(T, 1) & C(T)
    Next T
    .Range("B2:B" & X + 1) = D
    .Range("A1:F1") = Array("DATE", "PARTICULARS", "CHQ.NO.", "WITHDRAWALS", "DEPOSITS", "BALANCE")
    
    End With
    
    End Sub
    This code is tailored with guess and approximation for given data. Pl check thoroughly with other data before using.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 04-13-2020, 09:57 PM
  2. [SOLVED] VB Code to arrange data in Table format
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-22-2019, 04:42 PM
  3. [SOLVED] Arrays incorrect in macro to re arrange data into table style format
    By antonio32 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-29-2017, 03:55 PM
  4. Unformatted Data Into Table Content
    By LesliePrabakar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-19-2016, 11:37 AM
  5. Need Help - Paste Special (Unformatted Text)
    By websters82 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-10-2013, 10:48 AM
  6. Link to Publisher as Unformatted Text
    By agentred in forum Excel General
    Replies: 0
    Last Post: 05-25-2010, 02:09 PM
  7. merge unformatted date with text
    By Art in forum Excel General
    Replies: 2
    Last Post: 03-18-2005, 02:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1