I have a worksheet that is used to generate on-demand reports. Once a report is generated, I would like to auto-fit the columns so that all of the data is visible to the user. Currently, I have the following code written to do this:
However, when I run a report, the columns are not autofitted as I expected they would be. I do have a merged cell across the top of the report, but I removed it temporarily to test if that was the issue and the result is still the same. I have also tried only autofitting one of the wider columns (e.g. .Columns("C:C").EntireColumn.AutoFit) with no success. My understanding of the .AutoFit function is that it behaves in the same manner as double-clicking on a column positioner, but that does not seem to be the case.![]()
Please Login or Register to view this content.
Bookmarks