VBA Experts,
I found this VBA code somewhere and tried implementing it in my workbook but am having trouble customizing it to my needs.
This code does a very good job at copying everything on a specific worksheet and transferring it to a new workbook. However, what I can't figure out is how to get the code to copy data from A6 until it finds the last row with data in column E. I have specific formatting i.e. borders and colors which I would like to keep but would like the actual data to be values only (no formulas). Can someone please help me with this?
Thank you so much in advance.
J
Sub copyToNewWorkbook()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
If MsgBox("Press Yes to copy the Invoice worksheet to a new Workbook" & vbCr & _
"New workbook will be saved in the folder the workbook it is currently saved in.." _
, vbYesNo, "NewCopy") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
On Error GoTo ErrCatcher
Sheets(Array("Invoicing")).Copy
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Range("A6:E").Copy
'ws.[A1].PasteSpecial Paste:=xlValues
ws.Range("A6:E").PasteSpecial Paste:=xlValues
Cells(1, 1).Select
Next ws
Cells(1, 1).Select
NewName = InputBox("Please Specify the name of your new workbook", "New Copy")
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xlsx"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
Bookmarks