Hi,
I need to consolidate 3 sheets in a workbook into one sheet in same workbook. The data from the 3 sheets need to be stacked underneath each other. Extra rows may be added in the future, so the macro need to copy the entire range of data.
The macro should Not loop through the whole workbook as the workbook contain other sheets as well that i don't want to copy data from.
Here is the process i need:
Sub copydataprocess()
Sheets("EWBudget 2013").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
Range("A1").Select
ActiveSheet.Paste
Sheets("RBBudget 2013").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
ActiveCell.Offset(20, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("MIBudget 2013").Select
ActiveCell.Offset(-44, -87).Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
ActiveCell.Offset(102, 0).Range("A1").Select
ActiveSheet.Paste
End Sub
In Summary. I need to copy all data from 3 sheets with same layout (excluding row 1 which are headings) into one Consolidated Data Sheet. The macro need to find the next empty row and paste the data there.
I have worked on the macro so shorten it and this is what i have so far, but its not working.
-------
Public iRow As Long
--------
Function FindBlankRow(ws) As Long
Dim jRow As Long, kRow As Long, iCol As Integer
Sheets(ws).Select
jRow = 0
For iCol = 1 To 256
kRow = Cells(Rows.Count, iCol).End(xlUp).row
If Cells(kRow, iCol).Value = "" Then
kRow = 0
End If
If kRow > jRow Then
jRow = kRow
End If
Next iCol
FindBlankRow = jRow + 1
End Function
---------
Sub ConsolidateSFData()
iRow = FindBlankRow("Consolidated SF Data")
Sheets("EWBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
iRow = iRow + 1 'increment iRow to the next blank row
Sheets("RBBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
iRow = iRow + 1
Sheets("MIBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = False
End Sub
--------
Will you be able to help me please solve this macro problem?
Thank you very much!!
JBester
I need to consolidate 3 sheets in a workbook into one sheet in same workbook. The data from the 3 sheets need to be stacked underneath each other. Extra rows may be added in the future, so the macro need to copy the entire range of data.
The macro should Not loop through the whole workbook as the workbook contain other sheets as well that i don't want to copy data from.
Here is the process i need:
Sub copydataprocess()
Sheets("EWBudget 2013").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
Range("A1").Select
ActiveSheet.Paste
Sheets("RBBudget 2013").Select
Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
ActiveCell.Offset(20, 0).Range("A1").Select
ActiveSheet.Paste
Sheets("MIBudget 2013").Select
ActiveCell.Offset(-44, -87).Range("A1").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Consolidated SF Data").Select
'Paste in next empty row starting in Column "A"
ActiveCell.Offset(102, 0).Range("A1").Select
ActiveSheet.Paste
End Sub
In Summary. I need to copy all data from 3 sheets with same layout (excluding row 1 which are headings) into one Consolidated Data Sheet. The macro need to find the next empty row and paste the data there.
I have worked on the macro so shorten it and this is what i have so far, but its not working.
-------
Public iRow As Long
--------
Function FindBlankRow(ws) As Long
Dim jRow As Long, kRow As Long, iCol As Integer
Sheets(ws).Select
jRow = 0
For iCol = 1 To 256
kRow = Cells(Rows.Count, iCol).End(xlUp).row
If Cells(kRow, iCol).Value = "" Then
kRow = 0
End If
If kRow > jRow Then
jRow = kRow
End If
Next iCol
FindBlankRow = jRow + 1
End Function
---------
Sub ConsolidateSFData()
iRow = FindBlankRow("Consolidated SF Data")
Sheets("EWBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
iRow = iRow + 1 'increment iRow to the next blank row
Sheets("RBBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
iRow = iRow + 1
Sheets("MIBudget 2013").Range("A2").End(xlToRight).End(xlDown).Copy
Sheets("Consolidated SF Data").Range("A" & iRow).Select
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=False _
, Transpose:=True
Application.CutCopyMode = False
End Sub
--------
Will you be able to help me please solve this macro problem?
Thank you very much!!
JBester