View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
gocush[_29_] gocush[_29_] is offline
external usenet poster
 
Posts: 252
Default a loop formula that filters and prints?

Selecting items around an app is not advisable and slows things down.
Here's code that will accomplish the task without selecting:

Sub Print_Records()
Dim oCell As Range
Dim EmplList As Range
Dim i As Integer

Set EmplList = Sheets("Sheet2").Range("A1:A" & Cells(Rows.Count,
1).End(xlUp).Row)
i = 2

For Each oCell In EmplList
With Sheets("Sheet1")
.Range("A" & i).AutoFilter Field:=1, Criteria1:=oCell.Value
.PrintOut Copies:=1
.Range("A" & i).AutoFilter
End With
i = i + 1
Next oCell

End Sub

"scrabtree23" wrote:

I have a table of data in Sheet1. Column A:A lists employee's names. I have
a macro that will take the data in Sheet1 Column A:A and past it in Sheet2
Column A:A, it then sorts it in alpha order and filters it to unique values.

I need a looping formula that will go to Sheet2 Cell A1 and then filter the
data table in Sheet1 Column A:A by this value and then print. I then need
the code to loop to Sheet2 Cell A2 and do the same filter and print on Sheet1
etc. I need this to loop until the first empty cell.

Or, some other method that would work. Please help. Thanks in advance.