+ Reply to Thread
Results 1 to 3 of 3

Normalize Data for inclusion into Pivot Table

Hybrid View

  1. #1
    Registered User
    Join Date
    08-31-2016
    Location
    South Dakota
    MS-Off Ver
    2016
    Posts
    12

    Normalize Data for inclusion into Pivot Table

    Hello,

    So I need to analyze a workbook similar to the one I've provided. Raw tab is basically what the data looks like and Pivot tab is what I need the data to look like to easily manipulate it with a pivot chart.

    I can achieve Pivot tab if I spend a lot of time moving data around... but is there an easier way to do this with a formula or macro?

    Thanks for the assistance!
    Attached Files Attached Files
    Last edited by abublitz; 09-28-2016 at 10:23 AM.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Normalize Data for inclusion into Pivot Table

    Maybe with this

    Sub test()
    Sheets.Add after:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = "result"
    Range("D1") = "Week Nr"
    With Sheets("Raw")
        .Range("A1", "C1").Copy Sheets("result").Range("A1")
        lr = .Range("A" & Rows.Count).End(xlUp).Row
        lc = .Cells(1, Columns.Count).End(xlToLeft).Column
        For x = 2 To lc Step 2
            j = 0
            qt = Application.CountIf(.Range(.Cells(2, x), .Cells(lr, x)), ">0")
            If qt > 0 Then
                ReDim arr(1 To qt, 1 To 4)
                j = j + 1
                For i = 2 To lr
                    If .Cells(i, x).Value > 0 And .Cells(i, x + 1).Value > 0 Then
                        arr(j, 1) = .Range("A" & i)
                        arr(j, 2) = .Cells(i, x).Value
                        arr(j, 3) = .Cells(i, x + 1).Value
                        arr(j, 4) = Application.IsoWeekNum(.Cells(i, x + 1))
                        j = j + 1
                    End If
                Next
                Sheets("result").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(UBound(arr), 4) = arr
            End If
        Next
    End With
    With Sheets("Result")
        .Columns.AutoFit
        .Range("C1").Copy
        With .Range("D1")
            .PasteSpecial Paste:=xlPasteFormats
        End With
    End With
    Application.CutCopyMode = False
    End Sub
    Kind regards

  3. #3
    Registered User
    Join Date
    08-31-2016
    Location
    South Dakota
    MS-Off Ver
    2016
    Posts
    12

    Re: Normalize Data for inclusion into Pivot Table

    Thank you LeoTaxi, that works perfectly so much time saved.

+ 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. criteria for inclusion in data set
    By sloanh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2015, 05:06 PM
  2. How to normalize data for pivot table.
    By ammartino44 in forum Excel General
    Replies: 1
    Last Post: 09-03-2014, 03:58 AM
  3. Normalize data
    By MrKickAss in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-17-2014, 12:13 PM
  4. Replies: 2
    Last Post: 10-26-2009, 06:43 AM
  5. How to normalize data
    By excellicious in forum Excel General
    Replies: 3
    Last Post: 02-05-2009, 11:20 PM
  6. VB Macro to normalize a table
    By hasardeux in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2009, 08:24 AM
  7. [SOLVED] Automatic Inclusion of Comments on Chart Data Points??
    By Mike P. from KC in forum Excel General
    Replies: 0
    Last Post: 04-06-2006, 11:40 AM

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