ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filtering data via VBA code (https://www.excelbanter.com/excel-programming/387142-filtering-data-via-vba-code.html)

[email protected][_2_]

Filtering data via VBA code
 
Hi all! I was wondering if there's a way to program in a filter.
Basically, I have 10 columns...column B contains either of 3 entries:
"Bound", "ANB", or "Declined". I want to be able to program a macro to
filter for any entries containing the word "Bound" in it, and then
copying it and pasting it in another workbook. Then, I want to
"unfilter" it and show all data, and I will copy this and paste in
another workbook. Can this be done via VBA? Thank you in advance!


Tom Ogilvy

Filtering data via VBA code
 
Sure.

Turn on the macro recorder. Select you data and apply an autofilter
(Data=Filter=Autofilter). In this column, select custom from the dropdown
and select Contains and type in Bound (or on of your other choices). Then
select all you data and do Edit=copy. Move to the destination sheet and do
Edit=Paste (only the visible rows will be copied). go back to the original
sheet and do Data=Filter=Autofilter to remove the filter. Turn off the
macro recorder. Look at the recorded code and modify it to suite your
needs.

--
Regards,
Tom Ogilvy


" wrote:

Hi all! I was wondering if there's a way to program in a filter.
Basically, I have 10 columns...column B contains either of 3 entries:
"Bound", "ANB", or "Declined". I want to be able to program a macro to
filter for any entries containing the word "Bound" in it, and then
copying it and pasting it in another workbook. Then, I want to
"unfilter" it and show all data, and I will copy this and paste in
another workbook. Can this be done via VBA? Thank you in advance!



merjet

Filtering data via VBA code
 
Sure. Turn on the macro recorder. Do your thing. Turn off the macro
recorder. The code will be in the VBE. If you want help modifying the
code, post again.

Hth,
Merjet




All times are GMT +1. The time now is 01:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com