+ Reply to Thread
Results 1 to 3 of 3

How to use arrays with if/end if statemens

  1. #1
    Registered User
    Join Date
    01-06-2013
    Location
    New York, EUA
    MS-Off Ver
    Excel 2013
    Posts
    77

    How to use arrays with if/end if statemens

    Hello everybody,

    The columns "A", "B", "C", "D" and "E" of "Sheet1" are filled with numbers, from 1 to 49.

    I need a macro to classify these rows with 5 numbers the following way:

    There are 5 arrays with the numbers:
    K = Array(1, 2, 3, 4, 5, 6, 7, 8, 9)
    L = Array(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)
    M = Array(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
    N = Array(30, 31, 32, 33, 34, 35, 36, 37, 38, 39)
    O = Array(40, 41, 42, 43, 44, 45, 46, 47, 48, 49)

    I need to write 3 IF / END IF statements so that:

    If the 5 numbers of the "Range(Cells(y, 1), Cells(y, 5))" belong to the same array, then copy to "Sheet 2". For example, a row with the numbers "1", "2'', "3", "4" and "5".

    and

    If the 5 numbers of the "Range(Cells(y, 1), Cells(y, 5))" belong to different arrays, then copy to "Sheet 3". For example, a row with the numbers "1", "10'', "20", "30" and "40".

    and

    If the "Range(Cells(y, 1), Cells(y, 5)" has 2 numbers in one array, 2 numbers in other array, and 1 number in another array then copy to "Sheet4". For example, a row with the numbers "1", "5", "22", "26" and "40".

    Any help is welcome.

    Thanks,

    John
    Last edited by JOAO12; 02-01-2013 at 05:53 PM.

  2. #2
    Registered User
    Join Date
    01-06-2013
    Location
    New York, EUA
    MS-Off Ver
    Excel 2013
    Posts
    77

    Re: How to use arrays with if/end if statemens

    Hi,

    After many hours of study and work, I finally reached my goal.

    I would like to thank everyone that has read this thread and tryied to help me.

    Best Regards,

    John

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: How to use arrays with if/end if statemens

    Its good your issue is solved, however, if you solve a problem yourself before anyone else has responded, please take a moment to describe your solution, chances are some other member will benefit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ 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