Welcome to the Board!
How do you want to combine them? Append them, add common cells together? Make them separate sheets in one workbook? Why VB.net or VB 6? Why not VBA?
hi,
I have many excel files and the format for all is same
(format of columns and rows)my question is how can I make a program that combine these to one Excel file with
VB.Net or VB 6 and If there is also a program it sounds great !
Welcome to the Board!
How do you want to combine them? Append them, add common cells together? Make them separate sheets in one workbook? Why VB.net or VB 6? Why not VBA?
I have used this code to combine several Workbooks. Each Workbook must be open for it to work. I only use to gather Timesheets from several employees (one sheet per book) into one Workbook
Sub Combine()
Dim NewFileName As String
Dim c As Integer
Dim SheetCount As Integer
NewFileName = ActiveWorkbook.Name
c = 1
Do Until c = 0
If Windows(c).Visible = True Then
Windows(c).Activate
MsgBox ("New file to be created")
NewFileName = Application.GetSaveAsFilename _
(, "Microsoft Excel Workbook (*.xls),*.xls")
ActiveWorkbook.SaveAs FileName:=NewFileName, _
FileFormat:=xlWorkbookNormal
NewFileName = ActiveWorkbook.Name
ActiveSheet.Select
c = 0
SheetCount = ActiveWorkbook.Sheets.Count
Else
c = c + 1
End If
Loop
For c = 1 To Workbooks.Count
If Windows(c).Parent.Name <> NewFileName And Windows(c).Visible = True Then
Windows(c).Activate
ActiveWorkbook.Sheets.Copy after:=Workbooks(NewFileName).Sheets(SheetCount)
End If
Next c
End Sub
may you send the soource code I don't know how to use this source code please send the program that u compiled !
regards
H.B
hello mgpco
The code that I have supplied will copy each sheet from any open Workbooks to the one running the code. You will have to set it up using the VB Editor in Excell. Click Alt F11 to open the Editor. Find the ThisWorkbook on the left of the screen. Click on it and use Insert>Module Then paste the code in.
Try this example Workbook
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks