Need macro help taking information from one tab and separating between 3 tabs.

Troy1

Board Regular
Joined
Jul 2, 2014
Messages
149
Excel 2010/Windows XP

Hello I am trying to make a macro that will take 3 different categories (Missed Nets, NF Per Drivers, and Missed Non-TPRS) from 1 tab and separate over to 3 tabs and put them into there proper tabs.

When I run the report from our computer system there all 3 mixed up on the first tab. I have the macro set up to create the new tabs for each category and then attempt to cut or copy the information from first tab named "Missed Nets"(first tab) into the proper tabs based on there category. For example I want to take all of the "NF Per Drivers" from category J on the 1st tab and copy into the "NF Per Drivers" tab.

I have attempted to record myself by placing a filter on column J then me copying it (via going to GO to special and copy visible cells only) into the appropriate tabs. Everything works good for the most part except that I notice it doesn't copy all of the information sometimes. Because our report totals changes every single day. Once the macro runs there is still some "NF Per Driver" rows and "Missed Non-TPRS" rows left over on the front page.

Is there a way to filter the categories and have them all copy over to the appropiate tabs even if the totals change for each category every day?

Code:
 Sub MissedNonTPRs_Basic()'
' MissedNonTPRs_Basic Macro
'


'
  With Application
        .ScreenUpdating = False
        .Calculation = xlManual
        .EnableEvents = False
End With
Sheets(1).Name = "Missed Nets"
    
    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    
    Columns("A:A").Select
    Selection.Delete Shift:=xlToLeft
    Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft
    Columns("D:D").Select
    Selection.Delete Shift:=xlToLeft
    Columns("K:K").Select
    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlToLeft
    Columns("M:M").Select
    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlToLeft
    Columns("O:O").Select
    Selection.Delete Shift:=xlToLeft
    Selection.Delete Shift:=xlToLeft
    Columns("O:O").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("O1").Select
    ActiveCell.FormulaR1C1 = "Valid Y/N"
    Range("P1").Select
    ActiveCell.FormulaR1C1 = "Frt PU Y/N"
    Range("Q1").Select
    ActiveCell.FormulaR1C1 = "Notified Y/N"
    Range("R1").Select
    ActiveCell.FormulaR1C1 = "Customer Contact"
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("B2").Select
    Range("K:K,L:L,M:M").Select
    Range("M1").Activate
    Selection.NumberFormat = "h:mm"
    Columns("K:L").Select
    Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
        SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
        ReplaceFormat:=False
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("M2").Select
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=($M2-$L2-($L2>$M2))>(1/24)"
    Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
    With Selection.FormatConditions(1).Font
        .Color = -16776961
        .TintAndShade = 0
    End With
    Selection.FormatConditions(1).StopIfTrue = False
    Selection.Copy
    Rows("2:5280").Select
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
    Columns("C:C").Select
    Selection.NumberFormat = "General"
    Range("G8").Select
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 10
    ActiveWindow.ScrollColumn = 11
    ActiveWindow.ScrollColumn = 12
    ActiveWindow.ScrollColumn = 13
    ActiveWindow.ScrollColumn = 12
    ActiveWindow.ScrollColumn = 11
    ActiveWindow.ScrollColumn = 10
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    Range("A2").Select
        Columns("J:J").Select
     ActiveWorkbook.Sheets(1).Sort.SortFields.Clear
     ActiveWorkbook.Sheets(1).Sort.SortFields.Add Key:=Range("J1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Sheets(1).Sort
        .SetRange Range("A2:S5280")
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("G8").Select
    ActiveWindow.SmallScroll Down:=-57
    Range("B2").Select
  
  With Application
        .ScreenUpdating = True
        .Calculation = xlAutomatic
        .EnableEvents = True
  End With
 Dim newsheet
Set newsheet = Sheets.Add(After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet)
newsheet.Name = "NF Per Driver"


 Dim newsheet2
Set newsheet = Sheets.Add(After:=Sheets(Worksheets.Count), Count:=1, Type:=xlWorksheet)
newsheet.Name = "Missed Non-TPRs"


    Sheets("Missed Nets").Select
    Columns("J:J").Select
    Selection.AutoFilter
    ActiveSheet.Range("$J$1:$J$5280").AutoFilter Field:=1, Criteria1:= _
        "NO FREIGHT"
    Rows("96:5555").Select
    ActiveWindow.SmallScroll Down:=-21
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("NF Per Driver").Select
    Range("A2").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Sheets("Missed Nets").Select
    Selection.Delete Shift:=xlUp
    Range("J4795").Select
    ActiveSheet.Range("$J$1:$J$4794").AutoFilter Field:=1, Criteria1:= _
        "MISSED NON-TPR"
    Rows("52:5246").Select
    ActiveWindow.SmallScroll Down:=-84
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Sheets("Missed Non-TPRs").Select
    Range("A2").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Sheets("Missed Nets").Select
    Selection.Delete Shift:=xlUp
    Range("J4753").Select
    ActiveSheet.Range("$J$1:$J$4750").AutoFilter Field:=1
    Columns("J:J").Select
    Selection.AutoFilter
    Rows("1:1").Select
    Selection.Copy
    Sheets("NF Per Driver").Select
    Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Cells.Select
    Cells.EntireColumn.AutoFit
    Rows("1:1").Select
    Selection.Copy
    Sheets("Missed Non-TPRs").Select
    Range("A1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A2").Select


End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,215,945
Messages
6,127,844
Members
449,411
Latest member
adunn_23

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top