Hi,
I made this code for my own purpose some years ago.Not actually same as you expected, but hopefully you can take advantage of it..
First, you must add Microsoft Excel Object Library by adding it on Tools>References
Second, modify following code as you need.
Dim ExcelApp As Excel.Application
Dim ExcelFile As Excel.Workbook
Dim ExcelSheet As Excel.Worksheet
Function OpenExcelFile(ExcelFileName As Variant, ExcelSheetName As Variant)
Set ExcelApp = CreateObject("Excel.Application")
On Error GoTo NoFile
Set ExcelFile = ExcelApp.Workbooks.Add(ExcelFileName)
On Error GoTo NOSheet
Set ExcelSheet = ExcelFile.Sheets(ExcelSheetName)
ExcelApp.Visible = True
NoFile:
If Err Then
Err.Clear
MsgBox "No file found. Incorrect path '" & ExcelFileName & "'"
End If
NOSheet:
If Err Then
Err.Clear
MsgBox "No sheet '" & ExcelSheetName & "' found on '" & ExcelFileName & "'"
End If
End Function
Private Sub CommandButton1_Click()
OpenExcelFile "D:\Yitno\Project\Logistic\bom\BOM ADM.xls", "Sheet1"
MsgBox "Contents of Cell (1,1) is '" & ExcelSheet.Cells(1, 1) & "'"
End Sub
Any hesitate please let me know