I run my code in Visual Studio 2017 but it didn't create the new workbook.

Private Sub Command1_Click()

Dim xlApp As Excel.Application

Dim wb1 As Excel.Workbook

Dim wb As Excel.Workbook

Dim sNewFullName As String

Dim wkbkname(0 To 2) As String

Dim i As Integer

wkbkname(0) = ("File1.xlsx")

wkbkname(1) = ("File2.xlsx")

wkbkname(2) = ("File3.xlsx")

sNewFullName = "Combined.xls"

xlApp = New Excel.Application

wb1 = xlApp.Workbooks.Open(wkbkname(0))

For i = 1 To 2

wb = xlApp.Workbooks.Open(wkbkname(i)) wb.Sheets(0).Copy(After:=wb1.Sheets(wb1.Sheets.Count)) ' wb.Close(SaveChanges:=False)

wb.Close(False)

Next

wb = Nothing wb1.SaveAs("C:\Users\as17aez\Documents\Merge_Excel_files\Combined.xls")

wb1.Close()

wb1 = Nothing

xlApp.Quit()

xlApp = Nothing

End Sub Could you help me fix it?

Thread: Merging Multiple Excel File to One Excel File w/Multiple Sheets Program at VB6

vbforums.com

A pleasant day everyone...!!! I just want to ask for your assistance in relation to my programming p…

More Aikaterini Stamou's questions See All
Similar questions and discussions