+ Reply to Thread
Results 1 to 5 of 5

Stuck on how to Reformat data blocks into list with only essential data

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    35

    Stuck on how to Reformat data blocks into list with only essential data

    excelcutout.jpg

    I need to format the above to look like this:

    excelcutout2.jpg

    The list is very long with it formatted like this. I need one column with the dollar amount and the adjacent column with the name and for it to repeat all the way down the list. Note some addresses have 2 lines.

    How can I do this? I'm trying to learn excel macros but am stuck here...

    Thanks for the reply!

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Stuck on how to Reformat data blocks into list with only essential data

    Hi-

    If the format is always like that, then willwork (untested) as I wrote in a text file;
    sub test()
    with columns(1)
    	set c=.find(":",,,1)
    		if not c is nothing then
    			f=c.address
    			do
    				sheets(2).cells(sheets(2).rows.count,1).end(xlup).offset(1).resize(,2).value=array(c.offset(,1).value,c.offset(4).value)
    			set c=.findnext(c)
    			loop until f=c.address
    		end if
    end with
    end sub
    Regards,
    event

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Stuck on how to Reformat data blocks into list with only essential data

    Give this a try

    Sub abc()
    Dim FoundCell As Range
    Dim LastCell As Range
    Dim FirstAddr As String
    Dim aData, n As Long
    
        With Range("A:A")
            Set LastCell = .Cells(.Cells.Count)
        End With
        Set FoundCell = Range("A:A").Find(What:=":", After:=LastCell)
        
        If Not FoundCell Is Nothing Then
            FirstAddr = FoundCell.Address
        End If
    
        ReDim aData(1 To Rows.Count, 1 To 2)
        Do Until FoundCell Is Nothing
            n = n + 1
            aData(n, 1) = Replace(FoundCell.Value, ":", "")
            aData(n, 2) = FoundCell.Offset(4).Value
            Set FoundCell = Range("A:A").FindNext(After:=FoundCell)
            If FoundCell.Address = FirstAddr Then
                Exit Do
            End If
        Loop
        
        Worksheets.Add
        Range("a1").Resize(n, UBound(aData, 2)) = aData
    End Sub
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Registered User
    Join Date
    10-23-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    35

    Re: Stuck on how to Reformat data blocks into list with only essential data

    Awesome!!! Thank you, works like a charm.

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Stuck on how to Reformat data blocks into list with only essential data

    If you are satisfied with the solution(s) provided, please remember to mark your thread as Solved.
    New quick method:
    Select Thread Tools (above first post on page) -> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word "Title" you will see a dropdown with the words "No prefix".
    Change to "Solved"
    Click Save
    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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