Results 1 to 17 of 17

Selection Process finding "x"s from within 7 columns

Threaded View

  1. #1
    Registered User
    Join Date
    08-11-2009
    Location
    Gilbert, Arizona, USA
    MS-Off Ver
    Excel 2003
    Posts
    82

    Selection Process finding "x"s from within 7 columns

    Hi I have a process in which I have to create a selection without bias. There are 9 categories in this selection process. The 1st and 2nd category already have code and they work differently from the rest. For the 3rd through the 8th categories I have to choose one from the 3rd category, then one from the 4th, etc. After the 8th category I start back at the 3rd and go to the 4th, ect. It ends when cell A1 reaches 30%.

    Its a little difficult to explain but the process is simple enough to understand once you see it. I have attached an example of the process. I have also started the code and left explanations within the code.

    Sub selection_process()
    
    Dim x As Range, lastRow As Long
    lastRow = ActiveSheet.UsedRange.Rows.Count
    On Error Resume Next
    
    'Sort Column L, Descending, and N, Ascending with a header row:
    Range("A2:AZ" & lastRow).Sort Key1:=Range("L2"), Order1:=xlDescending, key2:=Range("N2"), _
    order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
    DataOption1:=xlSortNormal
    
    'Place a "1" in SEL column for each row which containS an "x" in column C.
    For Each x In Range("C2:C" & lastRow)
        If x.Value = "x" Then
           x.Offset(0, -1) = "1"
        End If
    Next x
    
    ''''''''''''START LOOP'''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    'start at cell E2 and go down to the first "x" in the column.
    'If column B of same row contains a number, go to next "x" below in column E
    'if column B of same row equals nothing, place a "3" in column B
    
    'start at active cell in E and go right one column and then down to the first "x" in the column.
    'If column B of same row contains a number go to next "x" below in column F
    'if column B of same row equals nothing, place a "4" in column B
    
    'start at active cell in F and go right one column and then down to the first "x" in the column.
    'If column B of same row contains a number, go to next "x" below in column G
    'if column B of same row equals nothing, place a "5" in column B
    
    'start at active cell in G and go right one column and then down to the first "x" in the column.
    'If column B of same row contains a number go to next "x" below in column H
    'if column B of same row equals nothing, place a "6" in column B
    
    'start at active cell in H and go right one column and then down to the first "x" in the column.
    'If column B of same row contains a number, go to next "x" below in column I
    'if column B of same row equals nothing, place a "7" in column B
     
    'start at active cell in I and go right one column and then down to the first "x" in the column.
    'If column B of same row contains a number, go to next "x" below in column J
    'if column B of same row equals nothing, place an "8" in column B
    
    'Then start the process over starting with '''''''start loop''''' above.
    
    'Continue the process until the formula in A1 reaches 30% (it will probably not be right at 30%, give or take a few percent)
    
    '''''''''''''END LOOP''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    
    End Sub
    I'm hoping there are just a few lines of code that I can loop until the cell A1 reaches 30%.

    Please help!
    Thank you!
    Curbster
    Attached Files Attached Files
    Last edited by curbster; 09-16-2009 at 06:54 PM. Reason: Solved

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