Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default a loop formula that filters and prints?

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default a loop formula that filters and prints?

Based on your givens, a loop like this should work.

Dim strEmpName As String
Sub Print_Records()
Sheet("Sheet2").Select
Range("A1").Select
Do Until ActiveCell.Value = ""
strEmpName = ActiveCell.Value
Sheets("Sheet1").Select
Range("A2").Select
Selection.AutoFilter Field:=1, Criteria1:=strEmpName
ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Sheet2").Select
ActiveCell.Offset(1, 0).Select
Loop

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
formula/function that prints only positve numbers Kara Hoover Excel Worksheet Functions 2 June 2nd 06 11:13 PM
How do write a formula so that only rows with info prints? help Excel Worksheet Functions 2 May 17th 06 05:07 PM
3 pg excel wrksht,pg 2 prints formula answers,insert pic behind MichelleatLouBachrodt Excel Discussion (Misc queries) 1 April 24th 06 07:05 PM
½ symbol prints a 2 and Winding square box prints a F frank-e Excel Discussion (Misc queries) 2 March 22nd 06 10:03 PM
Filters, Subtotal & Intacted Results after the filters' Removal kasiopi Excel Discussion (Misc queries) 5 February 24th 06 12:18 PM


All times are GMT +1. The time now is 12:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"