princess21
New Member
- Joined
- Jun 10, 2011
- Messages
- 15
In Excel I am trying to copy data from a closed workbook stored in a seperate folder location to a master workbook. I am trying to clone the data by selecting set rows from the closed workbbok to the master workbook. I have successfully tested copying select columns of data from one worksheet to another worksheet within the same workbook see code below -
Sub Sheet1tSheet1nsfer()
Sheets("Sheet1").Select
Cells.Find("table1").Offset(1, 0).Select 'finds the cell with the name table1
Do Until ActiveCell.Offset(0, 3) = ""
If ActiveCell <> "" And ActiveCell.Offset(0, 3) <> "m" And ActiveCell.Offset(0, 4) <> "" Then 'if the cell is blank of contains m do not copy over
ActiveCell.Offset(0, 3).Value = "m" 'this step adds an m in column 3 to prevent dulplicate copying over of old data
ActiveCell.Offset(0, 2).Copy
Sheets("Sheet2").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1 'adds contents to the next available row from the bottom up
Cells(NextRow, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues 'pastes data from column 2 in sheet1 to column 2 of sheet2
Sheets("Sheet1").Select
ActiveCell.Copy
Sheets("Sheet2").Select
Cells(NextRow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues 'pastes data from column 1 in sheet1 to column 1 of sheet2
Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub
How do I implement this technique and expand it to draw data from several workbooks from different folder locations to the master workbook.
P.S As you can see there are other features in this code that I need to maintain. Including a bit that prevents the copying over of duplicate values.
Sub Sheet1tSheet1nsfer()
Sheets("Sheet1").Select
Cells.Find("table1").Offset(1, 0).Select 'finds the cell with the name table1
Do Until ActiveCell.Offset(0, 3) = ""
If ActiveCell <> "" And ActiveCell.Offset(0, 3) <> "m" And ActiveCell.Offset(0, 4) <> "" Then 'if the cell is blank of contains m do not copy over
ActiveCell.Offset(0, 3).Value = "m" 'this step adds an m in column 3 to prevent dulplicate copying over of old data
ActiveCell.Offset(0, 2).Copy
Sheets("Sheet2").Select
NextRow = Cells(Rows.Count, 1).End(xlUp).Row + 1 'adds contents to the next available row from the bottom up
Cells(NextRow, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues 'pastes data from column 2 in sheet1 to column 2 of sheet2
Sheets("Sheet1").Select
ActiveCell.Copy
Sheets("Sheet2").Select
Cells(NextRow, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues 'pastes data from column 1 in sheet1 to column 1 of sheet2
Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
End Sub
How do I implement this technique and expand it to draw data from several workbooks from different folder locations to the master workbook.
P.S As you can see there are other features in this code that I need to maintain. Including a bit that prevents the copying over of duplicate values.