****updated as sort now works, only need how to autofit rows, dynamically without defining rows to autofit. Columns withh always be same and can be hard code***
Newbie here, with limited VBA.
I have a current project, and although my question may seem basic, considering how many steps I have completed accurately, I cannot seem to autofit all rows, without defining the rows.
I can do it by a range, but every month the amount of entries on the report differs.
My macro essentials takes a report (name changes every month as it is exported by another application in a messy Excel format) and cleans it up. Later it will be transposed by other methodology into a SharePoint datasheet list.
I spell everything out in steps as I am more a workflow writer. If there is anything I can clean up to simplify, Id learn to love that as well.
Macro is as follows: (please forgive formatting errors from trying to copy into Question)
Sub ComponentBalRptCleanup()
'Unmerge all Cells in Worksheet
ActiveSheet.Cells.UnMerge
'Delete Columns A1 thru D1
Range("A1:D1").EntireColumn.Delete
'Delete Rows A1 thru A9
Range("A1:A9").EntireRow.Delete
'Cut and Paste Cells
Range("A2").Cut Range("A1")
Range("G1").Cut Range("F1")
Range("P1").Cut Range("O1")
Range("AA1").Cut Range("Z1")
'Sort by Column A to Remove Extra Rows from View
Columns("A:AN").Sort key1:=Range("A:A"), order1:=xlAscending, Header:=xlYes
'Auto Fit Contents in Columns and Rows
ActiveCell.Columns("A:AG").EntireColumn.Select
ActiveCell.Columns("A:AG").AutoFit
ActiveCell.Rows("1:77").EntireRow.Select
ActiveCell.Rows("1:77").EntireRow.AutoFit
'Delete Empty Columns
Range("B:B, D:D, G:I, K:L, N:N, P:Q, T:V, X:Y, AA:AB, AD:AF").EntireColumn.Delete
'Remove Wrap Text from Cell B1
Range("B1").WrapText = False
'Autofit Contents of Columns
Range("A1:AF1").Columns.AutoFit
'Autofit Row A2 Contents
Range("A2:A2").Rows.AutoFit
'Save File As
Application.GetSaveAsFilename
End Sub