storemannequin
Board Regular
- Joined
- May 29, 2010
- Messages
- 108
Code:
Sub WeeklyNotificationV2()
Dim ActveWb As Workbook, SlsWb As Workbook
Dim ActveWs As Worksheet, SlsWs As Worksheet
Dim FnlRw As Long, FnlCol As Long, i As Long
Application.ScreenUpdating = False
Set ActveWb = ActiveWorkbook
Set ActveWs = ActveWb.ActiveSheet
FnlRw = ActveWs.Cells(Rows.Count, 1).End(xlUp).Row + 1
FnlCol = ActveWs.Cells(1, Columns.Count).End(xlToLeft).Column
With Range("B2:B" & FnlRw)
.Replace "/", " ", xlPart
End With
LastPln = ActveWs.Cells(2, 1).Value
LastNme = ActveWs.Cells(2, 2).Value
StartRw = 2
For i = 2 To FnlRw
ThisPln = ActveWs.Cells(i, 1).Value
ThisNme = ActveWs.Cells(i, 2).Value
If ThisPln = LastPln Then
Else
LastRw = i - 1
Rowcount = LastRw - StartRw + 1
Set SlsWb = Workbooks.Add(template:=xlWBATWorksheet)
Set SlsWs = SlsWb.Worksheets(1)
ActveWs.Range(ActveWs.Cells(1, 3), ActveWs.Cells(1, FnlCol)).Copy Destination:=SlsWs.Range("A1")
ActveWs.Range(ActveWs.Cells(StartRw, 3), ActveWs.Cells(LastRw, FnlCol)).Copy _
Destination:=SlsWs.Cells(2, 1)
SlsWs.Name = "UOM Same"
'-------------------------------------------------
With SlsWs.PageSetup
.PrintTitleRows = "$1:$1"
.PrintTitleColumns = ""
.LeftHeader = "&""Arial,Bold""&12Sales" & Chr(10) & LastPln & Chr(10)
.CenterHeader = _
"&""Calibri,Bold""&14" & LastNme & Chr(10) & " Discontinued List" & Chr(10)
.RightHeader = "&""Arial,Bold""&12Date Created:" & Chr(10) & Date
.LeftFooter = "&F DK"
.CenterFooter = "&8&P of &N" & Chr(10) & "Information"
.CenterFooter = "Page &P of &N" & Chr(10) & "Information"
.CenterHorizontally = True
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1000
.PrintGridlines = True
End With
'-------------------------------------------------
With SlsWs.Rows("2:2")
.VerticalAlignment = xlBottom
.WrapText = False
End With
Cells.EntireColumn.AutoFit
FN = LastNme & " Discontinued Item List " & Format(Date, "mm-dd-yyyy") & ".xlsx"
FP = ActveWb.Path & Application.PathSeparator
SlsWb.SaveAs Filename:=FP & FN
SlsWb.Close savechanges:=False
LastPln = ThisPln
LastNme = ThisNme
StartRw = i
End If
Next i
End Sub