Good morning,
I work for a manufacturing company, and I've been trying to create a new spreadsheet that will split data of Non-conforming material based on a supplier number into a new sheet. I would also like each new sheet to be in the form of a table. My goal would be to link each table to one slicer that sorts data based on week ending dates. From there, I can email each supplier their own list of non-conforming material for the week.
I realize that I can accomplish some of this by "Show report filter pages..." pivot table function, but the problem is, this database is refreshed daily, and when a new supplier that hasn't been in our database before shows up, the pivot tables have already been created and there won't be a new page with a new pivot table for the new supplier (My data source for the pivot tables goes the entire length of the columns).
I have also tried parsing data using the code below, but I find that it only runs effectively one time initially. So if I try to run the macro again, it won't split new data. Also, this code below doesn't do anything with formatting the data/keeping data in table form.
Sub parse_data()
Dim lr As Long
Dim ws As Worksheet
Dim vcol, i As Integer
Dim icol As Long
Dim myarr As Variant
Dim title As String
Dim titlerow As Integer
vcol = 14
Set ws = Sheets("NON-CON_PARTS")
lr = ws.Cells(ws.Rows.Count, vcol).End(xlUp).Row
title = "A1:S1"
titlerow = ws.Range(title).Cells(1).Row
icol = ws.Columns.Count
ws.Cells(1, icol) = "Unique"
For i = 2 To lr
On Error Resume Next
If ws.Cells(i, vcol) <> "" And Application.WorksheetFunction.Match(ws.Cells(i, vcol), ws.Columns(icol), 0) = 0 Then
ws.Cells(ws.Rows.Count, icol).End(xlUp).Offset(1) = ws.Cells(i, vcol)
End If
Next
myarr = Application.WorksheetFunction.Transpose(ws.Columns(icol).SpecialCells(xlCellTypeConstants))
ws.Columns(icol).Clear
For i = 2 To UBound(myarr)
ws.Range(title).AutoFilter field:=vcol, Criteria1:=myarr(i) & ""
If Not Evaluate("=ISREF('" & myarr(i) & "'!A1)") Then
Sheets.Add(after:=Worksheets(Worksheets.Count)).Name = myarr(i) & ""
Else
Sheets(myarr(i) & "").Move after:=Worksheets(Worksheets.Count)
End If
ws.Range("A" & titlerow & ":A" & lr).EntireRow.Copy Sheets(myarr(i) & "").Range("A1")
Sheets(myarr(i) & "").Columns.AutoFit
Next
ws.AutoFilterMode = False
ws.Activate
End Sub
My columns range from A-S, my columns with the supplier number I want data split by is in column N (VCOL = 14), and my week ending dates are in column Q (VCOL = 17)
I'm fairly inexperienced with VBA, but I've been resourceful in accomplishing smaller tasks. I'm a bit out of my depth on this apparently.
Thanks for help!
Bookmarks