Filter data and copy to new worksheet macro code

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
197
Office Version
  1. 2013
Platform
  1. Windows
I have an excel sheet with below columns and data.


Excel 2007
ABCDEFGHIJKLMN
1Client Event Tracking
2
3DateAug-15Jul-15Jan-15Jul-14
4New EventPebble BeachUS OpenLeadershipUS Open
5Client NameCASIDBankerBanker EmailGroupExecutive TitleExecutive Actual TitleExecutive Name
6Abc Inc123Dan, HEnergyCEOAcceptedYes
7Xyz LLC231Sam, KNortheastCFONoPostpone
8PQR Ltd876Nik, KMidwestTreasurerYes
9BBQ Equity435Sank, MEnergyOtherMaybe
10Dominos Inc232Dee, GTechnologyCEOCheckChange
Output



Now from the above data, i want to see data for Client 'Abc Inc' ONLY. So, I will put filter on Column A5 and select the client from Column A5 and then paste the visible data to new worksheet. see below for the output.



Excel 2007
ABCDEFGHIJK
1Client Event Tracking
2
3DateAug-15
4321New EventPebble Beach
5Client NameCASIDBankerBanker EmailGroupExecutive TitleExecutive Actual TitleExecutive Name
6Abc Inc123Dan, HEnergyCEOAccepted
Sheet1



similarly if i want to see data for Group - Energy, then i will go to column E5, select energy and copy paste the visible data to new worksheet

basically i want to create 5 button so the user can select the criteria based on below

Button1 - Client - when click on this button, one should be able to see all the client list and then select any of the client/clients. similarly for Banker, Group, Event button mentioned below
Button2 - Banker
Button3 - Group
Button4 - Event
and then when one click on 5th button i.e. Generate one should get the output based on the above filters in the new worksheet.

Let me know if you have any doubts?
 
Last edited:
In addition to what Peter sayd, I am still convinced that you are solicitating people in developing a useless feature, ie replacing the Excel filter button with another button; Excel experts indeed have the attitude to exploit at their maximum the features the program offer (and you payd to get them).
That said, I spent some time developing an interface a little bit more sophisticated that the filter buttons.
This is demonstrated in the sample workbook that you can download from here: https://www.dropbox.com/s/75utb1r93mb5wz8/FormFilter.xls?dl=0

Starting from Sheet1, use the available button to start a form.
It will show 4 listboxes that will be filled by the available filter values; the worksheet get filered as you select an available value.
Indeed the form is not fully programmed:
-listbox1, 2 and 3 are populated with the available list of value
-listbox1 and 2 also apply the filter when a value is selected
So Listbox4 need to be populated with the list of values, and Listbox3 and 4 need the filter mechanism to be added.
You have to replicate what has been done with Listbox1 and 2 (and partially Listbox3):
-populate the Listbox on ListBox_Enter event macro
-manage the filter on ListBox_Change event

There are two commandbutton with a basic programming: one just invoke the Sub CopyFilt that I already suggested (it will copy the filtered worksheet to anothe sheet), the other remove all filters and close the userform.

If you feel the same approach can be useful in your workbook, then you can "Export" the form from my workbook and import it in your wb: select the form in the Project-VbaProject (left frame of vba editor), Menu /File /File Export
This will create a ".frm and a ".frx" file; then from vba of your workbook excecute a File /Import of the ".frm" file.

Bye
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
HI Anthony. This is what i am looking for. Thnx for the User form. this is really helpful. I was not aware about the auto filter criteria of Excel. Excel is very Vast and people like you gives an opportunity to people like me to learn excel stuff. Thnx a Lot and Happy New Year in Advance.
 
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,711
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top