+ Reply to Thread
Results 1 to 2 of 2

Writing an If, Else If Statement in VBA

  1. #1
    Registered User
    Join Date
    11-04-2014
    Location
    Los Angeles
    MS-Off Ver
    2007
    Posts
    14

    Writing an If, Else If Statement in VBA

    I would like to write an if statement, but I don't know the proper way to write it. Basically, it's just

    If R3 = 1 Then
    ActiveSheet.Range("$R$3:$AA$67").AutoFilter Field:=1,
    Else if R3 = 2 then
    ActiveSheet.Range("$R$3:$AA$67").AutoFilter Field:=2,
    else if R3=3 then
    ActiveSheet.Range("$R$3:$AA$67").AutoFilter Field:=3,
    end if


    The part I don't know how to write is the "R3=<value>" portion, and I'm not sure if I structured the if, else if part correctly. Please help!

  2. #2
    Forum Contributor
    Join Date
    02-24-2013
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    317

    Re: Writing an If, Else If Statement in VBA

    You were close.

    I represented cell R3 two different ways for you. Either work.

    Please Login or Register  to view this content.
    You just need to add a criteria for the filter value. Something like this;
    Please Login or Register  to view this content.
    Last edited by Jim885; 11-05-2014 at 04:44 PM.
    If I helped in any way, please click the star

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need help with writing an IF statement
    By rcocalm in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2014, 03:18 PM
  2. [SOLVED] Writing an AND or OR statement
    By rcocalm in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-15-2013, 09:25 AM
  3. [SOLVED] Writing an =if statement with contains
    By 1Monkey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-12-2012, 12:21 PM
  4. IF Statement: How would I go about writing this
    By Bailey031285 in forum Excel General
    Replies: 2
    Last Post: 08-22-2011, 11:29 AM
  5. writing a statement
    By newexceluser in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-21-2006, 05:25 PM

Tags for this Thread

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