Hi,
Hi,
I have written the following program code:
Dim xlApp As New Excel.Application
Dim xlwrkBk As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strXLS As String
strXLS = "c:\Access\Myfile.xls"
Set xlwrkBk = xlApp.Workbooks.Open(strXLS)
Set xlSheet = xlwrkBk.Worksheets("singles")
Set c = xlSheet.Cells.Find(minfoxls, LookIn:=xlValues)
' minfolxls is a string variable)
If c Is Nothing Then
Else
a = c.ADDRESS
xlSheet.Range(a).EntireRow.Delete
xlwrkBk.Save
End If
xlwrkBk.Close 'Close the spreadsheet object
Set xlSheet = Nothing 'Delete the worksheet object
Set xlwrkBk = Nothing 'Delete the spreadsheet object
xlApp.Quit 'Close the excel application object
Set xlApp = Nothing 'Delete the application object
The program is stopping at " Set xlSheet = xlwrkBk.Worksheets("singles")"
and I am receiving the following error box:
Runtime error 9
Subscript out of range.
I don't understand this error because I am using the same program code with
another Excel file in another module and it works perfectly.
Thanks for help.
Daniel
Hi,
I have written the following program code:
Dim xlApp As New Excel.Application
Dim xlwrkBk As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim strXLS As String
strXLS = "c:\Access\Myfile.xls"
Set xlwrkBk = xlApp.Workbooks.Open(strXLS)
Set xlSheet = xlwrkBk.Worksheets("singles")
Set c = xlSheet.Cells.Find(minfoxls, LookIn:=xlValues)
' minfolxls is a string variable)
If c Is Nothing Then
Else
a = c.ADDRESS
xlSheet.Range(a).EntireRow.Delete
xlwrkBk.Save
End If
xlwrkBk.Close 'Close the spreadsheet object
Set xlSheet = Nothing 'Delete the worksheet object
Set xlwrkBk = Nothing 'Delete the spreadsheet object
xlApp.Quit 'Close the excel application object
Set xlApp = Nothing 'Delete the application object
The program is stopping at " Set xlSheet = xlwrkBk.Worksheets("singles")"
and I am receiving the following error box:
Runtime error 9
Subscript out of range.
I don't understand this error because I am using the same program code with
another Excel file in another module and it works perfectly.
Thanks for help.
Daniel