To make a note about Dick, this is correct, but I would not recommend using a For Each loop. For each, a temporary link is created to the COM cell behind the scenes, to which you do not have access (what you need to get rid of it).
See below for more details:
How to clean Excel interaction objects correctly?
To illustrate this problem, try an example for each example, close the application and look at the Task Manager. You should see that the Excel instance is still working (as all objects have not been deleted properly).
A cleaner way to handle this is to query the table using ADO:
http://technet.microsoft.com/en-us/library/ee692882.aspx
Mark Avenius Oct. 06 2018-10-10 18:21
source share