Rename the excel sheet name with Actual file name of Excel


I want to merge 4 excel files into 1 file .All files having different name so I want that After it merged into 1 file all files have there own sheet in file with there orignal names of it.So we can determine every sheet with there orignal names.


If all 4 files are in 1 folder

Get all the file paths in array using Directory.GetFiles(strPath), loop through it

Then read the content of the first Excel using Read Range and Store it in a datatable variable.

Then use write range to paste the datatable in the new Excel (output Excel) and in sheet name simply pass the file name without extension


item is the loop variable of for loop that will have the current file path in Loop

@rahulsharma Thanks for reply , Please can you share a demo of it.


Find attached code for your reference

Combining Excel (2.8 KB) (31.2 KB)

Hope this will help you

Mark as solution, so that it will help for other also



Can you try as below then


Hope this works for you


Instead of

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.