I am trying to make my table columns autofit to width. I have the following code which works on the first sheet with Table1 but after the next sheet is copied and becomes the active sheet the next line errors out with "Application defined or object defined error" and will not autofit the columns on Sheet 2
Code:
Private Sub SAVE_QUOTE_Click()
Dim Quotation As Worksheet: Set Quotation = ThisWorkbook.Sheets("Quotation")
ActiveSheet.Unprotect
Quotation.Range("I4") = Quotation.Range("I4") + 1
Application.DisplayAlerts = False
'Copy Quote to a New Workbook
Dim NewFN As Variant
Dim wb As Workbook
Set wb = Workbooks.Add
ThisWorkbook.Sheets("Quotation").Copy After:=wb.Sheets(1)
ActiveSheet.ListObjects(1).Range.Columns.AutoFit
ThisWorkbook.Sheets("Internal Use Only").Copy After:=wb.Sheets(2)
ActiveSheet.ListObjects(1).Range.Columns.AutoFit
Set wb = Nothing
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
'Sheets("Sheet3").Activate
ActiveWindow.SelectedSheets.Delete
[\code]
The remainder of my save function works like it should, I just need to resize the columns on this 2nd sheet.
Thanks!