The following code works fine if the sheet being imported is formatted as a table, and the table is renamed. What I am trying to do is import the sheet no matter if it has table formatting or not, rename the table if it does, make a table and rename it if it doesn't.
Dim fileDialog As fileDialog
Dim dialogTitle As String
Dim wbSource As Workbook
Dim strpathfile As String
dialogTitle = "Navigate to and select In Shop file"
Set fileDialog = Application.fileDialog(msoFileDialogFilePicker)
With fileDialog
.InitialFileName = "C:\Users\User\In Shop"
.AllowMultiSelect = False
.Filters.Clear
.Title = dialogTitle
strpathfile = .SelectedItems(1)
End With
Set wbSource = Workbooks.Open(Filename:=strpathfile)
Application.WindowState = xlNormal
Worksheets(1).Select
Worksheets(1).Copy After:=Workbooks("Evac Status Report.xlsm").Sheets("Program Commands")
wbSource.Close savechanges:=False
Worksheets(2).Select
Worksheets(2).Name = "W1PL62 In Shop Work"
'Rename In Shop Table
With ActiveSheet
.ListObjects(1).Name = "InShopWork"
End With
Set fileDialog = Nothing
Set wbSource = Nothing
Bookmarks