Results 1 to 44 of 44

pivot table not listing things in one row

Threaded View

  1. #23
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: pivot table not listing things in one row

    HI COLTS12OG

    This Code works on your Sample File. It'll need to be reworked a bit to handle your Real File. Please provide the information requested.

    The Merge Rows Code was adapted from Code written by Jindon here
    http://www.excelforum.com/excel-prog...e-columns.html

    Run the Code with Sheet yty active. Let me know of issues.
    Option Explicit
    Dim LR As Long
    Dim LC As Long
    Dim Rng As Range
    Dim i As Long
    
    Sub Delete_Empty_Rows()
        With ActiveSheet
            LR = .Cells.Find("*", .Cells(Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
                    SearchDirection:=xlPrevious).Row
    
            LC = .Cells.Find(What:="*", After:=[A1], _
                    SearchOrder:=xlByColumns, _
                    SearchDirection:=xlPrevious).Column
            Set Rng = .Range("D2:D" & LR)
            With Rng
                For i = LR To 1 Step -1
                    Application.ScreenUpdating = False
                    If Not IsNull(Rng(i).Resize(1, LC - 3).Text) Then
                        Rng(i).EntireRow.Delete
                    End If
                Next i
            End With
            .UsedRange.Replace What:="-*", Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, _
                    MatchCase:=False, SearchFormat:=False, ReplaceFormat:=True
    
            Call Merge_Rows
            
            .UsedRange.Offset(1, 3).NumberFormat = "h:mm"
        End With
        Application.ScreenUpdating = True
    
    End Sub
    
    ' From http://www.excelforum.com/excel-programming-vba-macros/893749-merge-duplicate-rows-and-combine-data-in-some-of-the-same-columns.html
    Sub Merge_Rows()
        Dim Dic As Object
        Set Dic = CreateObject("Scripting.Dictionary")
        With Range("A1").CurrentRegion
            For i = 1 To .Rows.Count
                If i < .Rows.Count Then
                    If Not Dic.exists(.Cells(i, 2).Value) Then
                        Set Dic(.Cells(i, 2).Value) = .Rows(i).Range(Cells(1, 4), Cells(1 & LC))
                    Else
                        Dic(.Cells(i, 2).Value).Value = _
                                .Parent.Evaluate(Dic(.Cells(i, 2).Value).Address & "&" _
                                & .Rows(i).Range(Cells(1, 4), Cells(1 & LC)).Address)
                        .Rows(i).EntireRow.Delete
                        i = i - 1
                    End If
                End If
            Next
        End With
    End Sub

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