Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel: How to Select Records and Print Them Out?

Status
Not open for further replies.

pvsmith5

Programmer
Mar 22, 2004
52
US
I have a client who wants to create a spreadsheet that will have a column that alternates between a "0" and "1" flag. He wants to send all the "1" flag records to a separate spreadsheet and print out the area. I could easily do this in Access with a query and make a new table, but how do you query for specific rows of records in Excel and send them to a new worksheet? And also, how do you format the print area to expand and contract with the length of the records selected? Also, I'm trying to do this in Excel 2007 and it is a little awkward for me.
 
Hi pvsmith5:

If I understand you correctly, you can use AdvancedFilter to extract records per specs in another worksheet for printing. Please try it and post back if you want to discuss this further.

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
 
Yes, Yogi, you're right, but he wants to do it with a macro so it is automated. I don't know if filters can be automated.
 
pvsmith5 said:
Yes, Yogi, you're right, but he wants to do it with a macro so it is automated. I don't know if filters can be automated.
Hi pvsmith5:

Yes the use of AdvancedFilter can be automated using VBA.

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
 



Hi,

Alternating 0 & 1 -
In a new column...
[tt]
=MOD(ROW(),2)
[/tt]
how do you query for specific rows of records in Excel ...

On a new sheet, Data/Get Extenal Data...
Using MS Query to get data from Excel faq68-5829
Query criteria on the new column 1/0 values.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Thanks for the posting, but unfortunately, Microsoft quit including MS Query in any Excel version past 2002. So I can't use this in 2007 or 2003. I'll try to do something with automating the Autofilter, but it doesn't look too clean.
 
.... I'll try to do something with automating the Autofilter, but it doesn't look too clean.
Hi pvsmith5:

If you want select records (those Flagged 1) extracted to a separate worksheet, the ideal way is to use AdvancedFilter with criterion ...

Flag = 1

You can use the criterion range with the column Label and 1 to make up the criterion or you can use computed criterion in a cell =Flag=1, and all the records Flagged 1 would be extracted.

And for automating you can perhaps use Worksheet_Change event to trigger execution of the AdvancedFilter automatically or you can have it triggered by clicking on a command button. I think this would be a very clean operation.

I hope this helps.

Yogi Anand, D.Eng, P.E.
Energy Efficient Building Network LLC
 



"Microsoft quit including MS Query in any Excel version past 2002. So I can't use this in 2007 or 2003"

Hmmmmmmmmm. That's odd. I've been using MS Query nearly every day in my Excel 2003 to return data from Oracle, DB2, MS Access, text files and Excel Workbooks.

Are you sure that you just failed to include that capability when you loaded MS Office?

I'd be lost without MS Query!!!

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Gotta read the "fine print"...
[tt][highlight white]
The following add-ins are no longer included with Excel 2002 and with later versions of Excel. However, they are available for download from the Excel section of the Microsoft Tools on the Web ( Web site. Alternatively, you can visit one of the following Microsoft Web sites:• Access Links (• Report Manager (• Template Wizard with Data Tracking (• ODBC Add-in (xlodbc.xla) (These following add-ins are no longer included with Excel 2002 and with later versions of Excel. Additionally, they are not available for download: • Autosave Add-in (Autosave.xla) [highlight yellow]
• MS Query [red]1.0/2.0 Compatibility (xlquery.xla) [/red][/highlight yellow]
• Template Utilities (tmpltnum.xla)
• Update Add-in Links (updtlink.xla)
[/highlight][/tt]

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 



BTW, MS Query is NOT an Add-In. XLODBC.XLA was.

Data/Get External Data...

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top