I have the following VBA code
Sub test2()
Set xlobj = GetObject("C:\Users\osknows\Desktop\One of each\Jan_2011.xls")
With xlobj
For Each wsobj In .Worksheets
Set rngobj = wsobj.UsedRange
arrArray = rngobj.Value
Next
End With
Erase arrArray
Set rngobj = Nothing
Set xlobj = Nothing
End Sub
The problem is that once this runs and exits the sub the Jan_2011.xls details are still in the VBA project window. I would expect this to disappear by setting xlobj = Nothing
Any ideas?
The line containing GetObject does two things: it opens the workbook and makes xlobj a reference to the workbook. When xlobj is set to nothing, the reference is cleared, but the workbook is still open. This can be avoided by adding the line
before emptying the variables.