Okay, I've been searching all morning and I'm having trouble getting this code to work:
Okay so this code works for me as it should opening a new WB pasting the info and prompting me to save the file.
The only issue here is that from the first WB I have AutoFit the columns A-D and this Formatting does not come over to the next workbook.
I've tried;
and multiple other codes but I can't get the Column width to transfer over to the new workbook without breaking the paste function itself.
Code:
Sub CommandButton1_Click()MyBook = ActiveWorkbook.Name ' Retrieves the name of original WB.
Columns("A:A").AutoFit
Columns("B:B").AutoFit
Columns("C:C").AutoFit
Columns("D:D").AutoFit
Range("A5:D500").Select
Selection.Copy
Workbooks.Add ' Opens my New Workbook
Sheets("Sheet1").Select
Sheets("Sheet1").Range("A1").Select
ActiveSheet.PasteSpecial
ActiveWorkbook.SaveAs Filename:="C:\........" ' Save name of new book
Workbooks(MyBook).Activate ' Back to the original WB
Application.CutCopyMode = False
End Sub
Okay so this code works for me as it should opening a new WB pasting the info and prompting me to save the file.
The only issue here is that from the first WB I have AutoFit the columns A-D and this Formatting does not come over to the next workbook.
I've tried;
Code:
[COLOR=#000000][FONT=Segoe UI]Range("A1").PasteSpecial Paste:=xlFormats
[/FONT][/COLOR]ActiveSheet.PasteSpecial Paste:=xlFormats
Worksheets("Sheet1").Range("A1").PasteSpecial Paste:=xlValues
and multiple other codes but I can't get the Column width to transfer over to the new workbook without breaking the paste function itself.