Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004

    Unanswered: selecting mutiple rows

    and I was hopeing to only have 4 questions. anyway I need to select mutiple rows depending on color I was working and I got this far but once selected I don't know how to keep it selected when I move onto the next row

    Sub sortgreen
    if interior.colorindex = 35 then
         do while interior.colorindex = 35
              next row
         next row
    selection.sort key1:=Range("b" & Activecell.row), xlAscending, xlguess, 1, _ false, xltoptobottom
    end Sub

  2. #2
    Join Date
    Apr 2004
    Derbyshire, UK
    Provided Answers: 1

    Selecting Sort Rows


    I am not sure how you have 'selected' the cell for the interior coumn to start with, but I have assummed it is te active cell!

    Also there seemed to be an error in you sort statement.

    Based on this I have listed a moded routine below which basically remenbers the top and bottm row numbers and then selects them.

    You can pick the bones from and mod as requied.

    Sub sortgreen()
        Dim TopRow As Integer
        Dim BotRow As Integer
        Dim i As Integer
        Dim iCol As Integer
        i = ActiveCell.Row
        iCol = ActiveCell.Column
        If Cells(i, iCol).Interior.ColorIndex = 35 Then
            TopRow = i
            i = i + 1
            Do While Cells(i, iCol).Interior.ColorIndex = 35
                i = i + 1
            BotRow = i - 1
            Rows("" & TopRow & ":" & BotRow & "").Select
            Selection.Sort key1:=Range("B" & iCol), Order1:=xlAscending, Header:=xlGuess, _
            OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
        End If
    End Sub


Posting Permissions

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