JBeaucaire,
Yes, of course. Changed code to reflect the desired column and it worked like a charm. The following is the code as it stands currently.
Option Explicit
Sub Sample()
Dim wbI As Workbook, wbO As Workbook
Dim wsI As Worksheet, wsO As Worksheet
'~~> Source/Input Workbook
Set wbI = ThisWorkbook
'~~> Set the relevant sheet from where you want to copy
Set wsI = wbI.Sheets("Mileage Approvals")
'~~> Destination/Output Workbook
Set wbO = Workbooks.Add
With wbO
'~~> Set the relevant sheet to where you want to paste
Set wsO = wbO.Sheets("Sheet1")
'~~> Copy the range
wsI.Range("A1:G400").Copy
'~~> Paste it in say Cell A1. Change as applicable
wsO.Range("A1:G300").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
wsO.Range("D1:G1").Value = [{"Mileage on Time Card","Overage", "Employee", "Week Ending"}]
'~~> Bold top row
Rows("1:1").Select
Selection.Font.Bold = True
'~~> Fit content to column and center text in columns B, C, D
wsO.Columns("B:B").HorizontalAlignment = xlCenter
wsO.Columns("C:C").HorizontalAlignment = xlCenter
wsO.Columns("D:D").HorizontalAlignment = xlCenter
wsO.Columns("E:E").HorizontalAlignment = xlCenter
wsO.Columns("F:F").HorizontalAlignment = xlCenter
'~~> Sets different column widths for columns A, B, C, D
Columns("A").AutoFit
Columns("B").ColumnWidth = 10
Columns("C").ColumnWidth = 10
Columns("D").ColumnWidth = 10
Columns("E").ColumnWidth = 10
Columns("F").ColumnWidth = 25
Dim LR As Long
LR = wsO.Range("A" & Rows.Count).End(xlUp).Row
wsO.Range("D2:E400" & LR).NumberFormat = "0"
LR = wsO.Range("A" & Rows.Count).End(xlUp).Row
wsO.Range("E2:E" & LR).Formula = "=IF(C2-D2<0, C2-D2,"""")"
LR = wsO.Range("A" & Rows.Count).End(xlUp).Row
wsO.Range("G2:G400" & LR).NumberFormat = "mm/dd/yy"
LR = wsO.Range("A" & Rows.Count).End(xlUp).Row
wsO.Range("G2:G" & LR).Formula = "=TODAY()-WEEKDAY(TODAY(),3)+IF(WEEKDAY(TODAY(),3)>4,11,4"
End With
End Sub
I'm still coming up short on how to adjust my code to adjust what is copied and pasted from the original workbook to the newly created workbook. This is what I'm trying to accomplish:
From the Original Workbook to the New Workbook
Column A-Copy and Paste ALL
Column B-Copy and Paste ALL
Column C-Copy and Paste ALL
Column D-Copy borders & cell background color only and Paste borders & cell background color only
Column E-Copy borders & cell background color only and Paste borders & cell background color only
Column F-Copy borders & cell background color only and Paste borders & cell background color only
Column G-Copy borders & cell background color only and Paste borders & cell background color only
Thanks again for any feedback you may be able/willing to offer.
Here's my Dummy workbook with the above code at work. Thanks.
Mileage Approval Spreadsheet DUMMY.xlsm
Matthew
Bookmarks