I am writing excel macros in vb.net coe to do certain things. There is a master sheet from which it reads emp ids & opens another secondary excel sheet. If emp id from master sheet don't change, secondary sheet should not be closed. If there is a change in emp id from master sheet, it should open another secondary sheet & continue to keep it open till another different emp id from master sheet is encountered.
Suppose, emp id 1111111 has 10 rows of data in master sheet. It should open secondary sheet corresponding to this emp id only once & keep it open till next emp id is encountered. Now secondary sheet opens 10 times & closes 10 times. This is making execution time too long. Instead, it should open only once & close once.
I have the code as follows. There must be better ways to make this happen. Any ideas please?
</CODE></CODE>
Suppose, emp id 1111111 has 10 rows of data in master sheet. It should open secondary sheet corresponding to this emp id only once & keep it open till next emp id is encountered. Now secondary sheet opens 10 times & closes 10 times. This is making execution time too long. Instead, it should open only once & close once.
I have the code as follows. There must be better ways to make this happen. Any ideas please?
Code:
For i = 1 to intMasterRows
For j = 1 to intMasterCols
If j = 3 Then
xlsSecInput = xlsApp.Workbooks.Open("C:\" & intEmpid & ".xls")
xlsSecWorksheet = xlsSecInput.Worksheets(1)
xlsSecRange = xlsSecWorksheet.UsedRange
<CODE to somethings here............
<CODE do to sometings here.............................
......................................................
......................................................>
End If
Next
xlsSecInput.Close(SaveChanges: = False)
Next