filmov
tv
Excel VBA Consolidate data from many worksheets into Master Sheet
Показать описание
This macro will help us to consolidate all our worksheets data into one master sheet. Very easy codes.
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
sheets("Master").Range("A2:G1000").ClearContents
Dim ws As Worksheet
For Each ws In worksheets
Lrow = sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row
If ws.Name 'Use not equal Sign here' "Master" Then
ws.UsedRange.Copy Destination:=sheets("Master").Range("A" & Lrow)
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
Private Sub CommandButton1_Click()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
sheets("Master").Range("A2:G1000").ClearContents
Dim ws As Worksheet
For Each ws In worksheets
Lrow = sheets("Master").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Row
If ws.Name 'Use not equal Sign here' "Master" Then
ws.UsedRange.Copy Destination:=sheets("Master").Range("A" & Lrow)
End If
Next
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub