I have several excel files that I want to merge together into a new excel file. Each excel files follow the same format, differing only in the number of rows they have. In each excel file, the top three rows are repeating (in Excel: File->Page Setup->Sheet->Print-Titles->Rows to Repeat at Top).
Iwas able to getthe files to merge together, but I cannot get thetop three rows to repeat at the top.How can I recreatethisbehavior using VB.net?
here is a snippet of my code:
'only write the repeating rows once
If fileCount = 1 Then
xlBook.ActiveSheet.Range(
"A1:H" & 3).Copy()
mergedXlBook.ActiveSheet.Range(
"A1:H" & 3).PasteSpecial(Excel.XlPasteType.xlPasteAll)
mergedXlBook.ActiveSheet.Range(
"A1:H" & 3).PasteSpecial(Excel.XlPasteType.xlPasteColumnWidths)
mergedXlBook.ActiveSheet.Rows.Autofit()
mergedXlBook.ActiveSheet.Columns.Autofit()
End If