I assigned the book to a variable. Then I do some things and save the file and close the book:
Is setting up the Nothing workbook a good idea if I want to use this code in a loop?
For i = 1 To UBound(a_ven_lst1)
Set wb_input1 = Application.Workbooks.Add
Set ws_input1 = wb_input1.Sheets(1)
.Rows(1).Copy ws_input1.Rows(1)
.Rows(d_fst_ven_row & ":" & d_lst_ven_row).Copy ws_input1.Rows(2)
s_save_path = f_str_file_name(ws_input1.Cells(2, i_ven_col_cnt).Value)
s_file_path = s_path & "\" & s_save_path & ".xlsx"
a_ven_lst1(i, 2) = s_file_path
wb_input1.SaveAs Filename:=s_file_path
wb_input1.Close True
Set wb_input1 = Nothing
Next i
Am I killing this variable appropriately? I saw some objects that still exist in the VBA editor after crushing the code, but far beyond this point.
source
share