Results 1 to 14 of 14

Help to add a different criteria to a existing macro

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Portugal
    MS-Off Ver
    Excel 2003
    Posts
    119

    Help to add a different criteria to a existing macro

    Hi guys.
    I need some help to add a new criteria, if possible, to this macro. What it does now is to when there is some change in some cells it will make a filter to a database to get all the values that match the criterias. Ill try to explain better.....So this is how it works, when one or all the cells "AF2", "AG2" and "AD2" are different then "AF4", "AG4" and "AD4" the macro make the filter in the database (B2:H5000) and gives me the values that match those criteria that is the AF3:AG4 range (values in AF4 and AG4).

    What im trying to do is that the macro make the filter searching to match exactly equal the value in AF4 (like its doing now) but in AG4 instead using that value what i need is that macro make the search with a interval, i mean supose that the value is 16, what i want is that it uses this value to search between 14 and 18 (equal to 14,15,16,17 and 18. 16+2 and 16-2) to give me more results in the end. Because now im limited to a single value to meet the criteria and im getting few results.
    Is this possible?
    This is my macro:


    Private Sub Worksheet_Calculate()
    
    If Range("AF2") <> Range("AF4") Or Range("AG2") <> Range("AG4") Or Range("AD2") <> Range("AD4") Then
        Application.EnableEvents = False
        Range("AD2:AG2").Value = Range("AD4:AG4").Value
        Range("B2:H5000").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range("AF3:AG4"), _
            CopyToRange:=Range("AH2:AN2"), Unique:=False
        
        Application.EnableEvents = True
    End If
    Many thanks
    Last edited by bazofio; 08-09-2014 at 04:03 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 07-07-2014, 09:48 AM
  2. Replies: 11
    Last Post: 11-04-2013, 04:32 PM
  3. Replies: 3
    Last Post: 10-14-2013, 03:06 PM
  4. [SOLVED] Adding additional selection criteria to existing Macro
    By Mogpot1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2013, 10:29 AM
  5. [SOLVED] Macro to take certain rows of data based on set criteria and past in to an existing sheert
    By Petmol in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2013, 01:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1