I have a process that is opening an existing excel sheet, changing the columns, fonts, colors etc. Then runs some automation against another system and puts more data in the sheet and then saves it. BUT for some reason the file size is jumping from 250kb to almost 67mb. How can I fix this? Below is all the code associated with excel.
Code:
Sub Fat_Cows_Come_Home_Slowly()
' Set excel information
Set wb = xlApp.Workbooks.Open("Opens the 250kb excel sheet. With 500 rows, 3 columns wide. ")
xlApp.Application.Visible = True
Set ws = wb.Sheets("Sheetname")
With ws
.Range("A1:Z999999").NumberFormat = "@"
.Range("A1:F1").Interior.Color = RGB(250, 204, 77)
.Range("A1:K1").Font.Bold = True
.Range("A1:Z99999").HorizontalAlignment = xlCenter
.Range("A1:Z99999").VerticalAlignment = xlCenter
.Range("A1:Z99999").RowHeight = 12.75
.Range("A1:Z99999").Font.Name = "Aparajita"
.Range("A1:Z99999").Font.Size = 12
.Cells(1, 4) = " Status "
.Cells(1, 5) = " Data Entered "
.Cells(1, 6) = " Complete? "
.Columns("E").ColumnWidth = 50
.Columns("F").ColumnWidth = 40
.Columns("A").ColumnWidth = 11.5
.Columns("B").ColumnWidth = 13.25
.Columns("C").ColumnWidth = 18.25
.Columns("D").ColumnWidth = 40
.Rows("2:2").Select
End With
if something then
ws.Cells(RowNum, 4) = "Reactivated - " & Variable
ws.Cells(RowNum, 6) = "No Changes Made"
ws.Cells(RowNum, 5) = "N/A"
end if
wb.SaveAs FileName:="New file, same 500 rows. Now upto 6 column wide. but now almost 67MB in size"
So am I doing something really dumb and paying the price in file size?