I have a problem with a piece of VBA code:
Sub Macro3()
Sheets("Output").Select
Rows("5:160").Select
Selection.Rows.AutoFit
End Sub
What – from my point of view it should do – is applying Autosize to Rows 5:160 within the Sheet “Output”. I added the code to the sheet “Output” so whenever I open it it should be properly resized automatically. However, nothing happens. But if I manually select the rows and press CRTL+C+H+O+A to auto size the rows it works properly.
Does anyone has a guess where the mistake lies? Would be a huge help!
Thanks upfront!
For this you have to place the code in the
ThisWorkbookcode area and you have to use theWorkbook_Open()eventSee this
SNAPSHOT