+ Reply to Thread
Results 1 to 3 of 3

Operators used in Macros

  1. #1
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Arrow Operators used in Macros

    Hi there,

    I need urgent help with my coding in Macro.. As you can see in Code 1 example Im trying to use an Autofilter to filter my cells with a Number Filter of is greater of equal to 4 and is less than or equal to 5.

    But as you can see I would like to customise is using a range of 2 values which i have specified in Cell P1 and Q1.

    I manage to figure out how to reference to this cell, but Im not sure how can i put my ">=" and "<=" operators into my code so i can get it to work exactly how i want as shown in Code 1.

    Code 1
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$K$118").AutoFilter Field:=6, Criteria1:=">=4", _
    Operator:=xlAnd, Criteria2:="<=5"

    Code 2
    Selection.AutoFilter
    ActiveSheet.Range("$A$1:$K$118").AutoFilter Field:=6, Criteria1:=Range("P1").Value, _
    Operator:=xlAnd, Criteria2:=Range("Q1").Value
    Thanks in advance..
    Last edited by newbie1234; 07-25-2009 at 03:26 AM.

  2. #2
    Forum Contributor
    Join Date
    04-11-2008
    Location
    Malaysia
    MS-Off Ver
    Office for Mac 2016
    Posts
    138

    Re: Operators used in Macros

    I did some trial and error and i solved it..

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Operators used in Macros

    try
    criteria:"<=" & Range("d1").Value
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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