Hi I need to re-use code as much as possible. I need to use the same procedure to open three different workbooks (one at a time) but it is not working.
This is what I have
How should I define NameFile (String?) so that I could use it in this lineCode:Public Sub AddRow(RowData As String, NameFile As String) Dim oXLApp As Excel.Application Dim oXLBook As Excel.Workbook Dim objExcelCI As Excel.Chart Dim oXLsheet As Excel.Worksheet Set oXLApp = New Excel.Application 'Create a new instance of Excel Set oXLBook = oXLApp.Workbooks.Open("C:\log\NameFile.xls") Set oXLsheet = oXLBook.Worksheets(1) End Sub
Set oXLBook = oXLApp.Workbooks.Open("C:\log\NameFile.xls")
with one of three names I have.
How should I call this function from any other sub?
Thanks




Reply With Quote