I am new to this forum and I would be very thankful if anyone can help me out.
I need a code that will copy certain cells from all sheets of all files in a folder and then list/paste them down in another master/summary sheet.
All workbooks in the folder have multiple sheets and in each sheet the cells which I want to copy are A2. B2 and C2
Example :
In work -Book1
Sheet 1
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47401[/TD]
[TD]ABC-1[/TD]
[TD]12345678[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47402[/TD]
[TD]ABC-2[/TD]
[TD]51354351[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 3
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47403[/TD]
[TD]ABC-3[/TD]
[TD]54542545[/TD]
[/TR]
</tbody>[/TABLE]
In work Book-2
Sheet 1
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37601[/TD]
[TD]xyz-1[/TD]
[TD]12345678[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37602[/TD]
[TD]xyz-2[/TD]
[TD]51354351[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 3
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37603[/TD]
[TD]xyz-3[/TD]
[TD]54542545[/TD]
[/TR]
</tbody>[/TABLE]
And so on.
I want to compile the highlighted cells in the following format in the summary file.
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47401[/TD]
[TD]ABC-1[/TD]
[TD]12,345,678[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]47402[/TD]
[TD]ABC-2[/TD]
[TD]51,354,351[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]47403[/TD]
[TD]ABC-3[/TD]
[TD]54,542,545[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]37601[/TD]
[TD]xyz-1[/TD]
[TD]12,345,678[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]37601[/TD]
[TD]xyz-2[/TD]
[TD]51,354,351[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]37603[/TD]
[TD]xyz-3[/TD]
[TD]54,542,545[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Any help would be appreciated. I have searched the internet for this and have found the following links but I wasn’t able to make them work.
http://www.mrexcel.com/forum/excel-questions/673353-macro-copy-data-multiple-excel-files.html
http://www.mrexcel.com/forum/excel-questions/508186-loop-through-folder-run-macro-all-workbooks.html
The following code does what I want for 1 workbook only
Sub Button10_Click()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
'Sub CopyData()
With ActiveSheet
.Range("A2").Select
Selection.Copy
Sheets("Proof Sheet").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
.Range("B2").Select
Selection.Copy
Sheets("Proof Sheet").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
.Range("C2").Select
Selection.Copy
Sheets("Proof Sheet").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End With
Application.ScreenUpdating = False
Next
Application.ScreenUpdating = False
Sheets("Proof Sheet").Select
End Sub
I can provide futher details if needed
thanks in advance
I need a code that will copy certain cells from all sheets of all files in a folder and then list/paste them down in another master/summary sheet.
All workbooks in the folder have multiple sheets and in each sheet the cells which I want to copy are A2. B2 and C2
Example :
In work -Book1
Sheet 1
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47401[/TD]
[TD]ABC-1[/TD]
[TD]12345678[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47402[/TD]
[TD]ABC-2[/TD]
[TD]51354351[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 3
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47403[/TD]
[TD]ABC-3[/TD]
[TD]54542545[/TD]
[/TR]
</tbody>[/TABLE]
In work Book-2
Sheet 1
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37601[/TD]
[TD]xyz-1[/TD]
[TD]12345678[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 2
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37602[/TD]
[TD]xyz-2[/TD]
[TD]51354351[/TD]
[/TR]
</tbody>[/TABLE]
Sheet 3
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]37603[/TD]
[TD]xyz-3[/TD]
[TD]54542545[/TD]
[/TR]
</tbody>[/TABLE]
And so on.
I want to compile the highlighted cells in the following format in the summary file.
[TABLE="width: 427, align: left"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]CODE[/TD]
[TD]PAGE[/TD]
[TD]BALANCE[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]47401[/TD]
[TD]ABC-1[/TD]
[TD]12,345,678[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]47402[/TD]
[TD]ABC-2[/TD]
[TD]51,354,351[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]47403[/TD]
[TD]ABC-3[/TD]
[TD]54,542,545[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]37601[/TD]
[TD]xyz-1[/TD]
[TD]12,345,678[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]37601[/TD]
[TD]xyz-2[/TD]
[TD]51,354,351[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]37603[/TD]
[TD]xyz-3[/TD]
[TD]54,542,545[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Any help would be appreciated. I have searched the internet for this and have found the following links but I wasn’t able to make them work.
http://www.mrexcel.com/forum/excel-questions/673353-macro-copy-data-multiple-excel-files.html
http://www.mrexcel.com/forum/excel-questions/508186-loop-through-folder-run-macro-all-workbooks.html
The following code does what I want for 1 workbook only
Sub Button10_Click()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
'Sub CopyData()
With ActiveSheet
.Range("A2").Select
Selection.Copy
Sheets("Proof Sheet").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
.Range("B2").Select
Selection.Copy
Sheets("Proof Sheet").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
.Range("C2").Select
Selection.Copy
Sheets("Proof Sheet").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End With
Application.ScreenUpdating = False
Next
Application.ScreenUpdating = False
Sheets("Proof Sheet").Select
End Sub
I can provide futher details if needed
thanks in advance