Ask Experts Questions for FREE Help !
Ask
    hollinshead's Avatar
    hollinshead Posts: 4, Reputation: 1
    New Member
     
    #1

    Feb 8, 2010, 01:59 AM
    How to create a filter using a macro
    Hi there, I wounder if you can help. I am creating a sales system in a database and have on one sheet a list of command buttons for which I use as a switch board type setup. On another sheet I have a range of columns holding relevant sales data. I would like to create a macro or bit of code for one of the command buttons on the main menu. Once selected this opens up the sales pipeline sheet and filters the data based on the data stored in a certain column. The column name is 'Business Area' which has repeating data such as 'software solutions' and 'Risk and Resilience' etc. Can you help?

    Thanks for your time and efforts in advance.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #2

    Feb 8, 2010, 05:17 AM

    Sure, post up your sample workbook and make sure it's evident where you want to set the controls to filter by, and what you want to trigger the activity.

    Click GO ADVANCED and use the paperclip icon to post up your workbook.

    ========
    NOTE: when you cross-post the same question on multiple forums, it is customary for you to provide links to the same question on the other forums. This insures people who decide to try and help can click over and see what other solutions have been offered, or see if you've already solved the query altogether.

    The last thing you want to do is waste people's time, yes? So add a link to your question on the other forum(s), too.
    hollinshead's Avatar
    hollinshead Posts: 4, Reputation: 1
    New Member
     
    #3

    Feb 9, 2010, 10:34 PM

    Thanks ever so much, I have attached a copy of my spreadsheet with some of the data in. I have also highlighted areas where I need work on, so if you could give me any guidance, I would really appreciate it. Thanks again.
    JBeaucaire's Avatar
    JBeaucaire Posts: 5,426, Reputation: 997
    Software Expert
     
    #4

    Feb 10, 2010, 02:34 AM

    1) Just fix the protection so that macros are free to work when the sheet is protected. The easiest way is to put a Worksheet_Activate macro into the Pipeline sheet so that each time you activate the sheet, the protections are corrected.
    Code:
    Private Sub Worksheet_Activate()
        Me.Protect , UserInterfaceOnly:=True, AllowFiltering:=True
    End Sub
    If you wanted to put in an actual password:
    Code:
    Private Sub Worksheet_Activate()
        Me.Protect "password", UserInterfaceOnly:=True, AllowFiltering:=True
    End Sub
    2) Notice the code above fixed the AutoFilter problem, too?

    3) This is better code for the FILTER button, it converts the button into a toggle and removes the unattractive "selecting".
    Code:
    Sub Button238_Click()
        Range("A7:BG97").AutoFilter
    End Sub
    4) The TIMELINE button only unhid the columns, it would work better as a toggle, no? This version of the macro flips the columns hidden/unhidden each time you click it:
    Code:
    Sub DisplayTimeLine()
        Columns("AB:BF").Hidden = Not Columns("AB:BF").Hidden
        Beep
    End Sub
    5) I've added the following CF formula to B8:AB96:
    Condition1: Formula Is:
    =AND($A8<>"", B8="")
    Format... pattern: RED.

    6) You have MAIN MENU buttons on each sheet, but you created a separate macro each time to do the same thing. No need. Just use one macro ToMain() and attach all of those buttons to it.
    Attached Files
  1. File Type: xls SalesandMarketingSystemB.xls (456.0 KB, 2349 views)
  2. ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #5

    Feb 10, 2010, 06:39 AM

    May I suggest that you are stretching the limits of Excel with this. I think you should consider porting this over to Access.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Excel Filter Macro needed [ 10 Answers ]

I have a list and want to filter it with reference to a cell. e.g. list is ranging from Row 5 to 2000, I want to assigne Cell A4 as reference to filter the data. When something is entered in A4 then it should check that A5 to A2000 has that data or not if yes then filter or else don't execute and...

When create a folder automatic create a same name .exe folder [ 3 Answers ]

When create a folder automatic a .exe folder create inside the parent folder with the same name please solve it and other was which antivirous software are best for Pc

Water Filter that will Filter Calcium [ 4 Answers ]

My husband is having trouble with kidney stones and they seem to be calcium stones. We would like to get a under the sink filter system that will filter the calcium (among other things). Can you suggest a good filtration system. We have well water. Thank you! :)

Create New Workbook Macro [ 3 Answers ]

I need to create a macro that creates a certain number of sheets in a workbook then creates a new workbook. What would you recommend be the maximum number of sheets in the workbook and what is the code to create a new workbook?

Pump won't lite after cleaning filter and inner filter [ 1 Answers ]

Filter was complet mush and guk, also in the pump I took out and cleaned the screen , all good now, I primed filter and pump but still would not ignite. Blnk blk blk, after 3 second hold button furnace attempts then must hold for 30 secs to reset from lockout. SO after many attemps, "does it every...


View more questions Search