Tke439

Buyer Report Code

Aug 2nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VBScript 18.39 KB | None | 0 0
  1. Sub Master()
  2.  
  3. If MsgBox("This is a demanding macro.  Please be sure to save any other work to avoid losing it.  This will take about 5 minutes.  Ready to start?", vbYesNo) = vbNo Then Exit Sub
  4.  
  5. Application.ScreenUpdating = False
  6.  
  7. '\\//CAO Processes
  8. Call RemoveDashOnes
  9. Call CAO_Report
  10. Call CAO_Breakout
  11. Call CAO_Clean
  12. '//\\
  13.  
  14. 'Delete Max Facings Column
  15. Sheets("Group_PositionList").Activate
  16. ActiveSheet.Range("K1").EntireColumn.Delete
  17.  
  18. 'Convert all movements & counts to numbers
  19. Dim lastcol As Long, lastrow As Long, GPL As Workbook
  20. lastcol = Sheets("Group_PositionList").Cells(1, Columns.Count).End(xlToLeft).Column
  21. lastrow = Sheets("Group_PositionList").Cells(Rows.Count, 1).End(xlUp).Row
  22.    
  23.     ActiveSheet.Range(Cells(2, 5), Cells(lastrow, lastcol)).Select
  24.         With Selection
  25.             .NumberFormat = "General"
  26.             .Value = .Value
  27.         End With
  28.        
  29. 'Get Estimated Reset Inventory, this tells the inventory for the additional stores carrying each item.
  30. 'Change all POG UPC counts to 1
  31. Call GetERI
  32.        
  33. 'Build Additional Stores Using Item Sheet
  34.    With ActiveWorkbook
  35.         .Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = "Addtnl Strs Per Item"
  36.     End With
  37. Sheets("Group_PositionList").Activate
  38.  
  39. '=====Copy the data=====
  40. Sheets("Group_PositionList").Range("A1:F" & Range("F" & Rows.Count).End(xlUp).Row).Copy
  41. 'Activate the destination worksheet
  42. Sheets("Addtnl Strs Per Item").Activate
  43. 'Select the target range
  44. Range("A1").Select
  45. 'Paste in the target destination
  46. ActiveSheet.Paste
  47. Application.CutCopyMode = False
  48.  
  49. Sheets("Group_PositionList").Activate
  50. Sheets("Group_PositionList").Range("J1:J" & Range("J" & Rows.Count).End(xlUp).Row).Copy
  51. 'Activate the destination worksheet
  52. Sheets("Addtnl Strs Per Item").Activate
  53. 'Select the target range
  54. Range("G1").Select
  55. 'Paste in the target destination
  56. ActiveSheet.Paste
  57. Application.CutCopyMode = False
  58.  
  59. '=====From Copy Headers=====
  60. 'Find Last Column Used
  61. lastcol = Sheets("Group_PositionList").Cells(1, Columns.Count).End(xlToLeft).Column
  62. lastrow = Sheets("Group_PositionList").Cells(Rows.Count, 1).End(xlUp).Row
  63. 'Copy through last header
  64. Sheets("Group_PositionList").Select
  65. ActiveSheet.Range(Cells(1, 11), Cells(lastrow, lastcol - 1)).Select
  66.     Selection.Copy
  67. 'Activate Target Worksheet
  68. Sheets("Addtnl Strs Per Item").Activate
  69. 'Select Target Range
  70. Range("H1").Select
  71. 'Paste in Target Destination
  72. ActiveSheet.Paste
  73. Application.CutCopyMode = False
  74. ActiveSheet.Cells.EntireColumn.AutoFit
  75.  
  76. '=====Run Input Macros=====
  77.  
  78. 'Run Input_PoG_Usage
  79. Call Input_PoG_Usage
  80.  
  81. 'Add header to last column
  82.    With ActiveSheet
  83.         Range("A1").End(xlToRight).Select
  84.         ActiveCell.Offset(, 1).Activate
  85. 'Changed from Number of stores carrying item
  86.        ActiveCell.Value = "Change in stores carrying"
  87.        
  88. 'Color Store Count
  89.        .Range("A1").End(xlToRight).Select
  90.             Selection.EntireColumn.Interior.Color = RGB(200, 200, 200)
  91.     End With
  92.    
  93. 'Run BuyerWarehouse
  94. Call BuyerWarehouse
  95.  
  96. 'Run Calculate
  97. Call Calculate
  98.  
  99. '=====Formatting=====
  100.  
  101. 'Color Rows based on Max Position Count
  102.    Range("A2:G" & Range("G" & Rows.Count).End(xlUp).Row).Select
  103.     Selection.FormatConditions.Add Type:=xlExpression, Formula1:="=$G2=0"
  104.     Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
  105.     With Selection.FormatConditions(1).Interior
  106.         .PatternColorIndex = xlAutomatic
  107.         .Color = 6908415
  108.         .TintAndShade = 0
  109.     End With
  110.     Selection.FormatConditions(1).StopIfTrue = False
  111.    
  112. 'Hide Group_PositionList Sheet
  113.    Sheets("Group_PositionList").Visible = False
  114.  
  115. 'Freeze Top Row, Rename Headers, & AutoFit Columns
  116. Rows("2:2").Select
  117.     With ActiveWindow
  118.         .SplitColumn = 0
  119.         .SplitRow = 1
  120.     End With
  121.     ActiveWindow.FreezePanes = True
  122. With ActiveSheet
  123.     .Range("A1").Value = "Order #"
  124.     .Range("B1").Value = "UPC"
  125.     .Range("E1").Value = "Current Store Count"
  126.     .Range("F1").Value = "Mvmnt"
  127.     .Cells.EntireColumn.AutoFit
  128.     .Range("A1").Select
  129. End With
  130.  
  131. 'Add Title & Reset Date
  132.    Rows("1:1").Select
  133.     Selection.Insert shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
  134.     Range("A1").Value = Application.InputBox("Buyer Report Title?")
  135.     Range("A2").Select
  136.     Selection.End(xlToRight).Select
  137.     Selection.Offset(-1, -2).Value = "Reset Date: "
  138.     Selection.Offset(-1, -2).HorizontalAlignment = xlRight
  139.     Selection.Offset(-1, -1).Value = Application.InputBox("Reset Date?")
  140.     Selection.Offset(-1, -1).HorizontalAlignment = xlLeft
  141.     Set GPL = ActiveWorkbook
  142. 'CAO Relocate
  143.    Call CAO_Relocate_New
  144.    
  145. 'Add Estimated Reset Inventory and multiply by Change in store count.
  146.    GPL.Sheets("Group_PositionList").Activate
  147.     ActiveSheet.Range("A1").Select
  148.     Selection.End(xlToRight).Select
  149.     Selection.Offset(, -1).Select
  150.     Range(Selection, Selection.End(xlDown)).Select
  151.     Selection.Offset(, 1).Select
  152.     Selection.Copy
  153.  
  154. 'Activate the destination worksheet
  155.    Sheets("Addtnl Strs Per Item").Activate
  156. 'Select the target range
  157.    With ActiveSheet
  158.         Range("A2").End(xlToRight).Select
  159.         ActiveCell.Offset(, 1).Select
  160.     End With
  161. 'Paste in the target destination
  162.    ActiveSheet.Paste
  163.     Application.CutCopyMode = False
  164.     With ActiveSheet
  165.         .Cells.EntireColumn.AutoFit
  166.         .Range("A:A").ColumnWidth = 9.6
  167.     End With
  168. 'Multiply by change in store count
  169. Dim e As Long, f As Long
  170.  
  171.     With Sheets("Addtnl Strs Per Item")
  172.     lastcol = .Cells(2, Columns.Count).End(xlToLeft).Column
  173.     lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
  174.     chng = .Cells(3, lastcol - 3).Column
  175.                
  176.         For e = 3 To lastrow
  177.             For f = lastcol To lastcol
  178.                 If Cells(e, lastcol).Value > 0 Then
  179.                       Cells(e, lastcol).Value = .Cells(e, lastcol).Value * Cells(e, chng).Value
  180.                 End If
  181.            Next
  182.         Next e
  183.     .Cells(1, lastcol).ColumnWidth = 11.25
  184.     .Range(Cells(2, lastcol), Cells(lastrow, lastcol)).Interior.ColorIndex = 43
  185.     .Range(Cells(2, lastcol), Cells(lastrow, lastcol)).EntireColumn.NumberFormat = "0"
  186.     .Cells(2, lastcol).Value = "Est Reset Inv"
  187.  
  188.         For e = 3 To lastrow
  189.             If Round(Cells(e, lastcol)) < .Cells(e, chng) Then
  190.                 .Cells(e, chng).Interior.ColorIndex = 43
  191.                 .Cells(e, lastcol).Interior.ColorIndex = 46
  192.             End If
  193.         Next e
  194.     End With
  195.    
  196. 'Hide POG Columns
  197.    Range("H1").Select
  198.     Range(Selection, Selection.End(xlToRight)).Select
  199.     Selection.EntireColumn.Hidden = True
  200.     Range("A2").End(xlToRight).Select
  201.     Selection.Offset(, -3).EntireColumn.Hidden = False
  202.  
  203.    
  204. 'Buyer Name Lookup
  205.    Range("A2").End(xlToRight).Select
  206.     Selection.Offset(, 1).Select
  207.     Selection.Value = "Buyer Name"
  208.  
  209.     Selection.Offset(1, 0).Activate
  210.     ActiveCell.FormulaR1C1 = _
  211.         "=IF(RC[-2]>1,VLOOKUP(RC[-2],'[Buyer Report Generator V5.xlsm]Buyer_Report_Generator'!R2C1:R38C2,2,FALSE),"""")"
  212.    
  213.     lastrow = Range("B2").End(xlDown).Row
  214.     ActiveCell.AutoFill Range(ActiveCell.Address, Cells(lastrow, ActiveCell.Column))
  215.  
  216.    
  217. 'Paste Values
  218.    Range("A2").Select
  219.     Selection.End(xlToRight).Select
  220.     Selection.EntireColumn.Copy
  221.    
  222.     Range("A2").End(xlToRight).Select
  223.     Selection.Offset(-1, 0).Select
  224.    
  225.     Selection.PasteSpecial Paste:=xlPasteValues
  226.     Application.CutCopyMode = False
  227.    
  228. 'Final AutoFit & add filters
  229.    ActiveSheet.Range("A2").End(xlToRight).Select
  230.     Selection.EntireColumn.AutoFit
  231.     ActiveSheet.Range("A2").AutoFilter
  232.     ActiveSheet.Range("A1").Select
  233.  
  234.     Workbooks("Buyer Report Generator V5.xlsm").Close False
  235.     GPL.Sheets("Addtnl Strs Per Item").Activate
  236.     MsgBox "Macro Complete"
  237.  
  238. End Sub
  239. Sub RemoveDashOnes()
  240. Dim lstrow As Long
  241.  
  242. lstrow = Sheets("Group_PositionList").Cells(Rows.Count, 2).End(xlUp).Row
  243.  
  244. For R = 2 To lstrow
  245.     If Right(Cells(R, 2).Value, 2) = "-1" Then
  246.         Cells(R, 2).EntireRow.Delete shift:=xlUp
  247.         R = R - 1
  248.     End If
  249. Next
  250.  
  251. End Sub
  252. Sub CAO_Report()
  253. Application.ScreenUpdating = False
  254.  
  255. 'Create new tab
  256. ActiveSheet.Copy After:=Worksheets(Sheets.Count)
  257. ActiveSheet.Name = "Distribution"
  258. ActiveSheet.Copy After:=Worksheets(Sheets.Count)
  259. ActiveSheet.Name = "CAO Report"
  260. Range("A:A").EntireColumn.Delete
  261. Range("B:J").EntireColumn.Delete
  262.  
  263. 'Format new tab and strip down to needed data
  264. Dim lstcol As Long, lastrow As Long, strnmbr As Range, Replace As String, Arng As Range
  265. lastrow = Sheets("CAO Report").Cells(Rows.Count, 1).End(xlUp).Row
  266. lstcol = Sheets("CAO Report").Cells(1, Columns.Count).End(xlToLeft).Column
  267. Set Arng = Range("A2:A" & lastrow)
  268.  
  269. For Each Cell In Arng
  270.     Cell.Value = Left(Cell, Len(Cell) - 1)
  271.     Cell.NumberFormat = "0000000000000"
  272. Next
  273. With Range("A:A")
  274.     .ColumnWidth = 14
  275.     .Value = Range("A:A").Value
  276. End With
  277.  
  278. 'Pull store numbers from POG names
  279. For c = 2 To lstcol
  280.     Set strnmbr = Cells(1, c)
  281.     Replace = Mid(strnmbr, Len(strnmbr) - 6, 3)
  282.     strnmbr = Replace
  283. Next c
  284.  
  285. End Sub
  286. Sub CAO_Breakout()
  287.  
  288. Application.ScreenUpdating = False
  289.  
  290. Dim P_ID As Range, lstcol As Long, lstrow As Long, caosht As Worksheet, _
  291. lstcol2 As Long
  292.  
  293. lstrow = Sheets("CAO Report").Cells(Rows.Count, 1).End(xlUp).Row
  294. lstcol = Sheets("CAO Report").Cells(1, Columns.Count).End(xlToLeft).Column
  295. Set caosht = ActiveWorkbook.Worksheets("CAO Report")
  296. Set P_ID = caosht.Range("A1:A" & lstrow)
  297.  
  298. 'Looper makes new tab for store, if it already exists, go to "ExistingStrNum"
  299. On Error GoTo ExistingStrNum
  300. Looper:
  301. For POG = 2 To lstcol
  302.     ActiveWorkbook.Sheets.Add(After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)).Name = caosht.Cells(1, 2).Value
  303.     P_ID.Copy
  304.     ActiveSheet.Paste
  305.     ActiveSheet.Range("A:A").ColumnWidth = 14
  306.     caosht.Range("B:B").Cut ActiveSheet.Range("B:B")
  307.     caosht.Range("B:B").EntireColumn.Delete
  308.      
  309. Next POG
  310. '\\//when loop finishes, go to "here" in order to skip error handling
  311. GoTo Here
  312.  
  313. 'Add duplicate store number data to existing tab
  314. ExistingStrNum:
  315. Application.DisplayAlerts = False
  316. ActiveSheet.Delete
  317. Application.DisplayAlerts = True
  318.  
  319. If caosht.Cells(1, 2) <> "" Then
  320.     Sheets(caosht.Cells(1, 2).Value).Activate
  321.     lstcol2 = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
  322. Else
  323.     GoTo Here
  324. End If
  325.  
  326. Cells(1, lstcol2 + 1).Activate
  327. caosht.Range("B:B").Cut ActiveSheet.Cells(1, lstcol2 + 1)
  328. caosht.Range("B:B").EntireColumn.Delete
  329.  
  330. Resume Looper
  331.  
  332. Here:
  333. Application.DisplayAlerts = False
  334. caosht.Delete
  335. Application.DisplayAlerts = True
  336.  
  337. End Sub
  338. Sub CAO_Clean()
  339.  
  340. Application.ScreenUpdating = False
  341.  
  342. Dim wbSource As Workbook, wbDest As Workbook, sht As Worksheet, sname As String, _
  343. relPath As String, lstrow As Long, lstcol As Long
  344.  
  345. 'Copying book
  346. Set wbSource = ActiveWorkbook
  347.  
  348. For Each sht In wbSource.Worksheets
  349.     If sht.Name = "Group_PositionList" Or sht.Name = "Distribution" Then
  350.     Else
  351.     lstcol = sht.Cells(1, Columns.Count).End(xlToLeft).Column
  352.     lstrow = sht.Cells(Rows.Count, 1).End(xlUp).Row
  353.     'For Each col In wbSource.Worksheets
  354.    On Error Resume Next
  355.     sht.Range("B2", Cells(lstrow, lstcol)).NumberFormat = "0"
  356.     sht.Range("B2", Cells(lstrow, lstcol)).Value = sht.Range("B2", Cells(lstrow, lstcol)).Value
  357.         If lstcol > 2 Then
  358.             For c = 2 To lstrow
  359.                 sht.Cells(c, 2).Value = WorksheetFunction.Sum(sht.Range(Cells(c, 2), Cells(c, lstcol)))
  360.             Next
  361.         Else
  362.         sht.Range("B2", Cells(lstrow, lstcol)).NumberFormat = "0"
  363.         sht.Range("B2", Cells(lstrow, lstcol)).Value = sht.Range("B2", Cells(lstrow, lstcol)).Value
  364.         End If
  365.     'Next col
  366.    End If
  367. Next sht
  368.  
  369.  
  370. For Each sht In wbSource.Worksheets
  371.     VBA.DoEvents
  372.     If sht.Name = "Group_PositionList" Or sht.Name = "Distribution" Then
  373.         Else
  374.         lstrow = sht.Cells(Rows.Count, 1).End(xlUp).Row
  375.         For y = 2 To lstrow
  376.             If sht.Cells(y, 1) <> "" Then
  377.                 If sht.Cells(y, 2).Value <> "0" Then
  378.                     sht.Cells(y, 2).EntireRow.Delete
  379.                     y = y - 1
  380.                     lstrow = lstrow - 1
  381.                 Else
  382.                     sht.Cells(y, 2).Value = sht.Cells(1, 2).Value
  383.                 End If
  384.             Else
  385.                 Exit For
  386.             End If
  387.         Next y
  388.     End If
  389. Next
  390.  
  391. End Sub
  392. Sub GetERI()
  393.  
  394. 'Estimated Reset Inventory
  395. 'Divide each POG's Units on Shelf by Each item's Units_Case, then average each line into new column.
  396. 'This will be multiplied by change in store count.
  397. Dim e As Long, lastrow As Long, lastcol As Long, f As Long, rng As Range, rng2 As Range
  398.  
  399.     With Sheets("Group_PositionList")
  400.         lastcol = .Cells(1, Columns.Count).End(xlToLeft).Column
  401.         lastrow = .Cells(Rows.Count, 1).End(xlUp).Row
  402.        
  403.         Set rng = ActiveSheet.Range(Cells(2, 11), Cells(lastrow, lastcol))
  404.        
  405. 'Change 0s to empty
  406.        For Each Cell In rng
  407.             If Cell.Value = 0 Then
  408.                 Cell.Value = Empty
  409.             ElseIf Cell.Value <> 0 Then
  410.                 Cell.Value = Cell.Value
  411.             End If
  412.         Next
  413.        
  414. 'Divide each PoGs' Units on Shelf by each item's Units_Case, then average each line into new column if value is not 0
  415.        For e = 2 To lastrow
  416.             For f = 11 To lastcol
  417.                 If Cells(e, f).Value <> Empty Then
  418.                       Cells(e, f).Value = .Cells(e, f).Value / Cells(e, 9).Value
  419.                       Cells(e, lastcol + 1).Value = Application.WorksheetFunction.AverageIf(Range(Cells(e, 11), Cells(e, lastcol)), ">0")
  420.                 End If
  421.            Next
  422.         Next e
  423.        
  424. 'Format new column
  425.    Range("A1").Select
  426.     Selection.End(xlToRight).Offset(, 1).Select
  427.     Selection.Value = "Avg Cs Pk"
  428.     Selection.EntireColumn.NumberFormat = "0.00"
  429.    
  430. 'If a value on Group Position List is  more than .01, make it 1.  If not, make it 0.
  431.  
  432.     For Each Cell In rng
  433.         If Cell.Value <> Empty Then
  434.             Cell.Value = 1
  435.         ElseIf Cell.Value = Empty Then
  436.             Cell.Value = 0
  437.             Cell.NumberFormat = "0"
  438.         End If
  439.     Next
  440.        
  441.     End With
  442.  
  443. Dim g As Long, lastcol2 As Long
  444.     For g = 2 To lastrow
  445.         lastcol2 = Sheets("Group_PositionList").Cells(1, Columns.Count).End(xlToLeft).Column
  446.         If Cells(g, lastcol).Value = "" Then
  447.             Cell.Value = "0"
  448.         End If
  449.     Next
  450.    
  451. End Sub
  452. Sub Input_PoG_Usage()
  453. 'Taken from Stackoverflow.com
  454. Dim sht As Worksheet, lastcol As Long, lastrow As Long, multiplier As Integer
  455.  
  456. Set sht = ActiveWorkbook.Worksheets("Addtnl Strs Per Item")
  457. lastcol = sht.Cells(1, sht.Columns.Count).End(xlToLeft).Column
  458.  
  459. Application.ScreenUpdating = False
  460. 'Double For Loop
  461. For i = 8 To lastcol
  462.     If Cells(1, i) <> vbNullString Then
  463.        
  464.         '     \\// Set so that every pog will be used one time; the code below in green will offer the input box for variable usages.
  465.        multiplier = 1
  466.         '     //\\Application.InputBox("Number of stores using set " & Cells(1, i) & ".", , 1)
  467.        lastrow = sht.Cells(sht.Rows.Count, 5).End(xlUp).Row
  468.  
  469.         For j = 2 To lastrow
  470.             Cells(j, i).Value = multiplier * Cells(j, i)
  471.         Next j
  472.     End If
  473. Next i
  474. Application.ScreenUpdating = False
  475.  
  476. End Sub
  477. Sub BuyerWarehouse()
  478.     With ActiveSheet.Select
  479.         Range("A1").End(xlToRight).Select
  480.     End With
  481.     ActiveCell.Offset(, 1).Activate
  482.     ActiveCell.Value = "Warehouse"
  483.     ActiveCell.Offset(, 1).Activate
  484.     ActiveCell.Value = "Buyer Number"
  485.  
  486. lastcol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
  487.  
  488. 'Copy the data
  489. Sheets("Group_PositionList").Range("G2:H" & Range("H" & Rows.Count).End(xlUp).Row).Copy
  490. 'Activate the destination worksheet
  491. Sheets("Addtnl Strs Per Item").Activate
  492. 'Select the target range
  493. Cells(2, lastcol - 1).Select
  494. 'Paste in the target destination
  495. ActiveSheet.Paste
  496. Application.CutCopyMode = False
  497.  
  498. End Sub
  499. Sub Calculate()
  500.  
  501. Dim i As Long, lastcol As Long, sht As Worksheet, lastrow As Long
  502.  
  503. Set sht = ActiveWorkbook.Worksheets("Addtnl Strs Per Item")
  504. lastcol = sht.Cells(1, sht.Columns.Count).End(xlToLeft).Column
  505. lastrow = sht.Cells(sht.Rows.Count, 5).End(xlUp).Row
  506.  
  507.     For i = 2 To lastrow
  508.         sht.Cells(i, lastcol - 2).Value = Application.WorksheetFunction.Sum(sht.Range(sht.Cells(i, 8), sht.Cells(i, lastcol - 3))) - sht.Cells(i, 5)
  509.     Next i
  510.  
  511. End Sub
  512. Sub CAO_Relocate_New()
  513. Application.ScreenUpdating = False
  514.  
  515. Dim wbSource As Workbook, wbDest As Workbook, sht As Worksheet, sname As String, _
  516. relPath As String, Srclstrow As Long, Dstlstrow As Long, lstrow As Long, fldrName As String, newbook As Workbook
  517.  
  518. Set wbSource = ActiveWorkbook
  519.  
  520. MkDir ("S:\Ryan Prince\CAO Reports POG\" & wbSource.Worksheets("Addtnl Strs Per Item").Range("A1").Value)
  521.  
  522. Set newbook = Workbooks.Add
  523. Workbooks("Buyer Report Generator V5.xlsm").Worksheets("DNO").Copy before:=newbook.Sheets(1)
  524.         Application.DisplayAlerts = False
  525.         newbook.Sheets("Sheet1").Delete
  526.         Application.DisplayAlerts = True
  527.         Set wbDest = newbook
  528.  
  529. For Each sht In wbSource.Sheets
  530.     If sht.Name = "Group_PositionList" Or sht.Name = "Distribution" Or sht.Name = "Addtnl Strs Per Item" Then
  531.     Else
  532.         'Destination book
  533.        Srclstrow = sht.Cells(Rows.Count, 1).End(xlUp).Row
  534.         Dstlstrow = wbDest.Worksheets("DNO").Cells(Rows.Count, 1).End(xlUp).Row
  535.        
  536.             sht.Range("A2:A" & Srclstrow).Copy wbDest.Worksheets("DNO").Range("C" & Dstlstrow)
  537.             sht.Range("B2:B" & Srclstrow).Copy wbDest.Worksheets("DNO").Range("A" & Dstlstrow)
  538.                                              
  539.             Application.DisplayAlerts = False
  540.             sht.Delete
  541.             Application.DisplayAlerts = True
  542.     End If
  543. Next
  544.  
  545. lstrow = wbDest.Worksheets("DNO").Cells(Rows.Count, 1).End(xlUp).Row
  546.  
  547. With wbDest.Worksheets("DNO")
  548.     .Range("C:C").ColumnWidth = 14
  549.     .Range("B2:B" & lstrow).Value = Date
  550.     .Range("E3:E" & lstrow).Value = Range("E2").Value
  551.     .Range("F3:F" & lstrow).Value = Range("F2").Value
  552.     .Range("H3:H" & lstrow).Value = Range("H2").Value
  553.     .Range("J3:J" & lstrow).Value = Range("J2").Value
  554.     .Range("L3:L" & lstrow).Value = Range("L2").Value
  555.     .Range("M3:M" & lstrow).Value = 0
  556.    
  557. End With
  558.  
  559. sname = wbDest.Worksheets("DNO").Cells(2, 1).Value & ".txt"
  560. relPath = "S:\Ryan Prince\CAO Reports POG\" & wbSource.Worksheets("Addtnl Strs Per Item").Range("A1").Value & "\" & "DNO"
  561.  
  562. wbDest.SaveAs Filename:=relPath, FileFormat:=xlTextWindows
  563. wbDest.Close False
  564.  
  565. End Sub
Add Comment
Please, Sign In to add comment