我想:
答案 0 :(得分:2)
要确定使用的范围,请使用Worksheet.UsedRange属性: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/worksheet-usedrange-property-excel?f=255&MSPPError=-2147217396
对于此范围内的自动调整列,请使用Range.AutoFit方法: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/range-autofit-method-excel?f=255&MSPPError=-2147217396
UsedRange = ActiveWorkbook.Worksheets.Item("Sheet1").usedrange
UsedRange.Columns.Autofit