Help needed
I need to make Pivot Tables from Data Consolidated from multiple pages.
The Data is of same format and has the same Headers.
The “Consolidate” procedure works just fine but the “GetRange” procedure is giving me problems.
Why do I need the “GetRange” procedure?
Well, its simple.
The multiple sheets are copied with headers.
Using the “GetRange” procedure I choose from which row to copy data i.e. without headers.
From the
“For ii = 3 To Sheets.Count 'from third list onwards”
The first sheet is copied ok
But when the next sheet is copied, it is not pasted.
NB: the file to contain this module must have a sheet.name = “form” in which the market Header is designed.
['=============================================================================================
'Assuming we have one Workbook named "Consolidate" which consolidates data from its different
'pages, we are in a position to make a pivot table.
'=============================================================================================
Sub consolidate()
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("ConsolidatedData").Delete
Sheets.Add Before:=Sheets(1)
Sheets(1).Name = "ConsolidatedData"
'the If proceedure always makes the sheet containing the form second
If Sheets(1).Name = "ConsolidatedData" Then
Sheets("form").Select
Application.CutCopyMode = False
Sheets("form").Move Before:=Sheets(2)
End If
GetHeader
'the cycle that copies all Data into the sheet named "ConsolidatedData"
Dim ii As Long
For ii = 3 To Sheets.Count 'from third list onwards
Sheets(ii).Activate ' change the active range to copy
GetRange
With Sheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(1)
.PasteSpecial xlValues
End With
Next ii
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Range("a1").Activate
End Sub
Sub GetHeader()
Workbooks("Consolidate").Worksheets("form").Select
Application.Goto Reference:="header"
Application.CutCopyMode = False
Selection.Copy
Sheets("ConsolidatedData").Select
Range("A1").Select
ActiveSheet.Paste
Columns("A:G").Select
Selection.ColumnWidth = 15
Range("A4").Select
End Sub
'=====================================================================
'this procedure excludes all rows pertaining to the Hearder
'
'A strange fact!!!!!
' When the procedure getRange is executed
' It copies the first page "Ëèñò5" but not the second "Ëèñò4"
'please help!!!
'=====================================================================
Sub GetRange()
Dim q As Integer
q = InputBox("How many rows not to copy?")
Workbooks("Consolidate").ActiveSheet.Range(Cells(q, 1), _
Cells(Workbooks("Consolidate").ActiveSheet.Rows.Count, _
Workbooks("Consolidate").ActiveSheet.Columns.Count)).Select
Selection.Copy
End Sub
][/code]
I need to make Pivot Tables from Data Consolidated from multiple pages.
The Data is of same format and has the same Headers.
The “Consolidate” procedure works just fine but the “GetRange” procedure is giving me problems.
Why do I need the “GetRange” procedure?
Well, its simple.
The multiple sheets are copied with headers.
Using the “GetRange” procedure I choose from which row to copy data i.e. without headers.
From the
“For ii = 3 To Sheets.Count 'from third list onwards”
The first sheet is copied ok
But when the next sheet is copied, it is not pasted.
NB: the file to contain this module must have a sheet.name = “form” in which the market Header is designed.
['=============================================================================================
'Assuming we have one Workbook named "Consolidate" which consolidates data from its different
'pages, we are in a position to make a pivot table.
'=============================================================================================
Sub consolidate()
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Sheets("ConsolidatedData").Delete
Sheets.Add Before:=Sheets(1)
Sheets(1).Name = "ConsolidatedData"
'the If proceedure always makes the sheet containing the form second
If Sheets(1).Name = "ConsolidatedData" Then
Sheets("form").Select
Application.CutCopyMode = False
Sheets("form").Move Before:=Sheets(2)
End If
GetHeader
'the cycle that copies all Data into the sheet named "ConsolidatedData"
Dim ii As Long
For ii = 3 To Sheets.Count 'from third list onwards
Sheets(ii).Activate ' change the active range to copy
GetRange
With Sheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(1)
.PasteSpecial xlValues
End With
Next ii
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Range("a1").Activate
End Sub
Sub GetHeader()
Workbooks("Consolidate").Worksheets("form").Select
Application.Goto Reference:="header"
Application.CutCopyMode = False
Selection.Copy
Sheets("ConsolidatedData").Select
Range("A1").Select
ActiveSheet.Paste
Columns("A:G").Select
Selection.ColumnWidth = 15
Range("A4").Select
End Sub
'=====================================================================
'this procedure excludes all rows pertaining to the Hearder
'
'A strange fact!!!!!
' When the procedure getRange is executed
' It copies the first page "Ëèñò5" but not the second "Ëèñò4"
'please help!!!
'=====================================================================
Sub GetRange()
Dim q As Integer
q = InputBox("How many rows not to copy?")
Workbooks("Consolidate").ActiveSheet.Range(Cells(q, 1), _
Cells(Workbooks("Consolidate").ActiveSheet.Rows.Count, _
Workbooks("Consolidate").ActiveSheet.Columns.Count)).Select
Selection.Copy
End Sub
][/code]