The complete code follows

Sub RunReportForEachCustomer() Dim IRange As Range Dim ORange As Range Dim CRange As Range Dim WBN As Workbook Dim WSN As Worksheet Dim WSO As Worksheet

Dim

wdApp

As

Word,

.Application

Dim

wdDoc

As

Word,

.Document

Dim

wdRng

As

Word,

.Range

Application.ScreenUpdating = False

Set WSO = ActiveSheet 1 Find the size of today's dataset FinalRow = Cells(65536, 1).End(xlUp).Row NextCol = Cells(1, 255).End(xlToLeft).Column + 2

1 First - get a unique list of customers in J ' Set up output range. Copy heading from D1 there Range("D1").Copy Destination:=Cells(1, NextCol) Set ORange = Cells(1, NextCol)

1 Define the Input Range

Set IRange = Range("A1").Resize(FinalRow, NextCol - 2)

' Do the Advanced Filter to get unique list of customers IRange.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=' CopyToRange:=ORange, Unique:=True

FinalCust = Cells(65536, NextCol).End(xlUp).Row

1 Loop through each customer

For Each cell In Cells(2, NextCol).Resize(FinalCust - 1, 1) ThisCust = cell.Value

0 0

Post a comment