Saving Excel data as csv with VBA - removing blank rows at end of file to save

后端 未结 2 1480
南方客
南方客 2021-01-19 05:12

I am creating a set of csv files in VBA.

My script is creating the data set I need, but the number of rows differs in multiple iterations of the loop. For instance,

2条回答
  •  余生分开走
    2021-01-19 05:55

    Excel saves the UsedRange. In order to truncate the UsedRange, you need to delete whole rows and save the file.

    If that's not an option, insert a new worksheet, copy the prepared data to it (thus leaving its UsedRange matching actual data), use Worksheet.SaveAs (as opposed to Workbook.SaveAs) and delete the worksheet.

    Although the actual problem here is why your UsedRange gets that big in the first place.

提交回复
热议问题