I am developing an application in VB, which reads an Excel file and extracts cell data and writes it to the itermediate window for right now.
I would like for the application NOT to have to be closed to be able to process a second file or group of files. Unfortunately, every other time I run the application from the development area I get the following error after a files has been processed and I select another file to be processed:
Run-time error '1004'
Method 'Range' of object '_Global'failed
When seletecting Debug VB is highlighting the following line of code:
Set WorkRange = Excel.Range("A2".Columns(1).EntireColumn
Below is the line of code before and after:
Dim WorkRange As Range
Set WorkRange = Excel.Range("A2".Columns(1).EntireColumn
Set WorkRange = Intersect(WorkRange.Parent.UsedRange, WorkRange)
Any suggestions?
I would like for the application NOT to have to be closed to be able to process a second file or group of files. Unfortunately, every other time I run the application from the development area I get the following error after a files has been processed and I select another file to be processed:
Run-time error '1004'
Method 'Range' of object '_Global'failed
When seletecting Debug VB is highlighting the following line of code:
Set WorkRange = Excel.Range("A2".Columns(1).EntireColumn
Below is the line of code before and after:
Dim WorkRange As Range
Set WorkRange = Excel.Range("A2".Columns(1).EntireColumn
Set WorkRange = Intersect(WorkRange.Parent.UsedRange, WorkRange)
Any suggestions?