Secondoncet

  • 格式:doc
  • 大小:38.50 KB
  • 文档页数:12

Dim curSheet As ObjectDim Crow, Ccol, i As LongDim compdate As DateDim friday As DateDim today As IntegerDim Vendor As StringDim UPCcol, VendorCol, VendornbrCol As Integer'delete vendor to Nancy 090308 '102511 Updtaed - Ethan Sub Secondonceaweek()Set curSheet = ActiveWorkbook.ActiveSheet'ɾ³ýÁÐApplication.DisplayAlerts = FalseApplication.ScreenUpdating = FalseColumns("U:U").SelectSelection.DeleteRange(Cells(2, 1), Cells(80000, 256)).Sort Key1:=Range("D1")Range(Cells(2, 1), Cells(80000, 256)).Sort Key1:=Range("T1")Cells.SelectSelection.AutoFilter Field:=35, Criteria1:="<>"r = [C1048576].End(xlUp).RowIf r <> 1 ThenRange("D2:D" & [C1048576].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllDataCells.SelectSelection.AutoFilter Field:=34, Criteria1:="*ASN#*"r = [C1048576].End(xlUp).RowIf r <> 1 ThenRange("D2:D" & [C1048576].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllDataCells.SelectSelection.AutoFilter Field:=18, Criteria1:="7"Selection.AutoFilter Field:=9, Criteria1:="C"r = [C1048576].End(xlUp).RowIf r <> 1 ThenRange("D2:D" & [C1048576].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData'Cells(1, 15).SelectColumns("R:R").CopyColumns("R:R").Insert Shift:=xlToRightCells.SelectSelection.AutoFilter Field:=18, Criteria1:="<>20"Selection.AutoFilter Field:=19, Criteria1:="<>3", Operator:=xlAnd, Criteria2:="<>7" r = [C1048576].End(xlUp).RowIf r <> 1 ThenRange("D2:D" & [C1048576].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllDataColumns("R:R").DeleteRange("AA1").SelectSelection.AutoFilter Field:=27, Criteria1:="<>", Operator:=xlAndr = [D65536].End(xlUp).RowIf r <> 1 ThenRange("D2:D" & [D65536].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData'Dim e As Long'e = 2'Do Until Cells(e, 17) = Empty''If Cells(e, 13) = "BABY CONSUMABLES" Then 'Rows(e).Select'' With Selection.Interior' .Pattern = xlSolid' .PatternColorIndex = xlAutomatic' .ThemeColor = xlThemeColorAccent3 ' .TintAndShade = 0.399975585192419 ' .PatternTintAndShade = 0' End With'''Else'End If'e = e + 1'Loop'curSheet.Activate'Sheets("DeleteVendor").Activatetoday = Weekday(Date)If today = 2 Then compdate = Date + 6If today = 3 Then compdate = Date + 5If today = 4 Then compdate = Date + 4If today = 5 Then compdate = Date + 3If today = 6 Then compdate = Date + 2friday = compdate - 2Cells.Select'ship dateCells(1, "S").SelectSelection.AutoFilter Field:=19, Criteria1:=">" & compdate, Operator:=xlAndr = [D65536].End(xlUp).RowIf r <> 1 ThenRange("S2:S" & [D65536].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData'cancel dateCells(1, "T").SelectSelection.AutoFilter Field:=20, Criteria1:="<=" & friday, Operator:=xlAndr = [D65536].End(xlUp).RowIf r <> 1 ThenRange("Q2:Q" & [D65536].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllData'curSheet.ActivateUPCcol = Look_In_KeyWord("UPC", "c")VendorCol = Look_In_KeyWord("VENDOR NAME", "c")'Crow = Fun_Rows_Columns_Count("rows", UPCcol, 100)VendornbrCol = Look_In_KeyWord("VENDOR NUM", "c")curSheet.SelectSheets.Add = "DeleteVendor"curSheet.SelectRange(Cells(1, 1), Cells(1, 256)).SelectSelection.CopySheets("DeleteVendor").SelectRange("A1").SelectActiveSheet.PastecurSheet.Activatei = 2j = 2Do Until curSheet.Cells(i, VendornbrCol).Value = EmptyVendor = curSheet.Cells(i, VendorCol).ValueIf InStr(UCase(Vendor), "ELEXA") > 0 Or InStr(UCase(Vendor), "JVC") > 0 OrInStr(UCase(Vendor), "CANON") > 0 _Or InStr(UCase(Vendor), "SONY") > 0 Or (InStr(UCase(Vendor), "PHILIPS") > 0 And ((InStr(UCase(Vendor), "PHILIPS DOMESTIC APPLIANCES") = 0) And (InStr(UCase(Vendor), "PHILIPS DOMESTIC APPLIANCES") = 0))) Or InStr(UCase(Vendor), "TTE TECHNOLOGY") > 0 _ Or InStr(UCase(Vendor), "SAMSUNG") > 0 Or InStr(UCase(Vendor), "DELL") > 0 OrInStr(UCase(Vendor), "DISGUISE") > 0 _Or InStr(UCase(Vendor), "HASBRO") > 0 Or InStr(UCase(Vendor), "MGA") > 0 _Or InStr(UCase(Vendor), "RADICA") > 0 Or InStr(UCase(Vendor), "EASTMAN KODAK") > 0 _ Or InStr(UCase(Vendor), "RADIO FLYER") > 0 Or InStr(UCase(Vendor), "PACIFIC CYCLE") > 0 Or InStr(UCase(Vendor), "ACER AMERICA") > 0 _Or InStr(UCase(Vendor), "P&F USA INC") > 0 Or InStr(UCase(Vendor), "P&F USA INC") > 0 ThenIf curSheet.Cells(i, VendornbrCol).Value <> "364342050" ThencurSheet.SelectRange(Cells(i, 1), Cells(i, 256)).SelectSelection.CopySheets("DeleteVendor").SelectCells(j, 1).SelectActiveSheet.PastecurSheet.SelectRange(Cells(i, 1), Cells(i, 256)).SelectSelection.Delete Shift:=xlUpj = j + 1i = i - 1End IfEnd Ifi = i + 1LoopSheets("DeleteVendor").ActivateCells.SelectSelection.AutoFilter Field:=34, Criteria1:="=*emailed*", Operator:=xlAndr = [D65536].End(xlUp).RowIf r <> 1 ThenRange("AH2:AH" & [D65536].End(xlUp).Row).SpecialCells(xlCellTypeVisible).Select Selection.EntireRow.DeleteEnd IfIf ActiveSheet.FilterMode = True Then ActiveSheet.ShowAllDataColumns("K:K").SelectSelection.CopyColumns("A:A").SelectSelection.Insert Shift:=xlToRight Columns("AF:AF").SelectSelection.CopyColumns("B:B").SelectSelection.Insert Shift:=xlToRight Columns("S:S").SelectSelection.CopyColumns("C:C").SelectSelection.Insert Shift:=xlToRight Columns("AU:AU").SelectSelection.CopyColumns("D:D").SelectSelection.Insert Shift:=xlToRightColumns("AJ:AJ").SelectSelection.CopyColumns("E:E").SelectSelection.Insert Shift:=xlToRightColumns("A:B").SelectSelection.Insert Shift:=xlToRight Range("A1") = "Name"Range("B1") = "Status"Columns("H:H").SelectSelection.Insert Shift:=xlToRightRange("H1") = "Days Past Ship"Columns("E:E").NumberFormatLocal = "0000000000"Columns("AC:AC").SelectSelection.Insert Shift:=xlToRightRange("AC1") = "MABD"Columns("AF:AF").SelectSelection.Insert Shift:=xlToRightRange("AF1") = "90% FILLED"Range("A1:BZ" & [D65536].End(xlUp).Row).CopySet tmpSheet = Workbooks.Add.Sheets(1)curSheet.ActivateWorkbooks("Book1").ActivateRange("a1").SelectActiveSheet.PasteRange(Cells(2, 1), Cells(10000, 100)).Sort Key1:=Range("F1") Range(Cells(2, 1), Cells(10000, 100)).Sort Key1:=Range("E1")Range(Cells(2, 1), Cells(10000, 100)).Sort Key1:=Range("D1")Range(Cells(2, 1), Cells(10000, 100)).Sort Key1:=Range("C1")Range("E2:E" & [D65536].End(xlUp).Row).Copy = "adv"Range("a1").SelectActiveSheet.PasteRange("A1:A65536").AdvancedFilter Action:=xlFilterInPlace, Unique:=TrueRange("A1:A" & [a65536].End(xlUp).Row).Copy = "SQL"Range("a1").SelectActiveSheet.PasteRange("B1:B" & [a65536].End(xlUp).Row) = "=TEXT(RC[-1],""0000000000"")" Range("C1:C" & [a65536].End(xlUp).Row) = "=""'""&RC[-1]&""',"""Sheets("sheet3").Name = "SQL results"'Sheets("adv").DeleteActiveWorkbook.SaveAs Filename:="C:\Mail\once\" & Format(Date, "mmddyy") &"_CHINA_OO_DETAILS--2nd email.xls", FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _False, CreateBackup:=FalseApplication.ScreenUpdating = True'**************************************************************************** MsgBox "Completed!"End Sub。