I am trying to get the code below to make a table for only the columns with data and to do so for every sheet in the workbook, and then after change the orientation of all sheets to landscape but its doing 2 things weird:
Not looping through sheets.
Making all columns into the table not just those with data.
Can it be done to only look for columns with data and format those into a table?
Sub Format_As_Table()
Dim tbl As ListObject
Dim rng As Range
Dim sh As Worksheet
For Each sh In ThisWorkbook.Sheets
Set rng = Range(Range("A1"), Range("A1").SpecialCells(xlLastCell))
Set tbl = ActiveSheet.ListObjects.Add(xlSrcRange, rng, , xlYes)
tbl.TableStyle = "TableStyleMedium15"
Next sh
Application.ScreenUpdating = False
Call Orientation
End Sub
'======================================================================
Sub Orientation()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Sheets
With ActiveSheet.PageSetup
.Orientation = xlLandscape
End With
Next sh
Application.ScreenUpdating = False
End Sub