Welcome toExcel.Tips.Net
Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site
Filtering Columns for Unique Values
Printing Multiple Worksheets on a Single Page
Vinod frequently uses Excel's advanced filtering tools to copy filtered data from one location to another. In some instances he would like to copy not only the cell contents but also the cell comments of the cells that meet the filtering criteria. He's not looking for a way to filter based on comments, but only to copy comments along with the cell contents when using the advanced filtering capabilities of Excel.
As far as we can tell, there is no way to copy comments using advanced filtering; only the cell contents are copied. However, it is possible to easily copy the comments using a two-step process.
First, use advanced filtering to filter your data, but make sure you do the filtering in-place; don't specify that you want the information copied to a different location. You end up with a filtered list, showing only the cells that meet your critieria. Next, select the cells returned by the filtering. You should then make sure that Excel knows you only want the visible cells selected:
With the visible cells selected (those hidden by the filtering are not selected), you are ready for the second step: Copy the cells to another location using normal editing techniques. The result is that the comments are copied right along with the cell contents.
If you perform this task quite a bit and it even bugs you to do the two steps, you could automate the task. The following macro will apply an advanced filter in-place, copy the visible cells to the Clipboard, and then paste them (and their comments) into a new workbook:
Sub AdvancedFilter_AndCopyComments()
With Range("Database")
' filter the data range
.AdvancedFilter Action:=xlFilterInPlace, _
CriteriaRange:=Range("Criteria"), Unique:=False
' copy visible cells only
.SpecialCells(xlCellTypeVisible).Copy
End With
' goto to another worksheet
Sheets("Sheet1").Select
' and paste the copied data
With Range("A1")
.PasteSpecial xlPasteColumnWidths
.PasteSpecial xlPasteAll
End With
Application.CutCopyMode = False
End Sub
The macro assumes you have two named ranges set up: one for the data to be filtered (Database) and the other for the filtering criteria (Criteria). Run the macro, and the filtered, commented information ends up on Sheet1.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3169) applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Change Formatting Based On Your Data! Conditional formatting provides a way for you to adjust the appearance of your data based on the data itself. Discover how to put this amazingly powerful feature to work for you, today. This comprehensive volume is available in two editions.