1) Create a blank sheet called Report in your workbook.
2) Right-click on the Report tab and select VIEW CODE
3) Paste in this sheet macro:
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
Application.EnableEvents = False
Call BranchParts
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
4) In the VBEditor, click on Insert > Module
5) Paste in this macro:
Option Explicit
Sub BranchParts()
'JBeaucaire (10/14/2009)
Dim Rng As Range, cell As Range, LR As Long
Sheets("Report").Cells.Clear
Sheets("Data").Activate
Range("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("E1"), Unique:=True
Range("E:E").Cut Sheets("Report").Range("A1")
With Sheets("Report")
.Range("A2:A255").Copy
.Range("B1").PasteSpecial xlPasteAll, Transpose:=True
.Range("A2:A255").Clear
Set Rng = .Range("B1", .Cells(1, Columns.Count).End(xlToLeft))
End With
If ActiveSheet.AutoFilterMode = False Then Range("A1").AutoFilter
For Each cell In Rng
Range("A1").AutoFilter Field:=1, Criteria1:=cell
LR = Range("A" & Rows.Count).End(xlUp).Row
If LR > 1 Then Range("B2:B" & LR).Copy cell.Offset(1, 0)
Next cell
ActiveSheet.AutoFilterMode = False
End Sub
6) Close the VBeditor and save your sheet.
Now, anytime you bring up the REPORT sheet onscreen, it will update itself using the macros you installed, so it will always be accurate.
Bookmarks