If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > selecting mutiple rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-05-04, 09:06
VBALordCorp VBALordCorp is offline
Registered User
 
Join Date: Jul 2004
Posts: 34
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

Code:
Sub sortgreen
if interior.colorindex = 35 then
     do while interior.colorindex = 35
          entirerow.select
          next row
     loop
else
     next row
selection.sort key1:=Range("b" & Activecell.row), xlAscending, xlguess, 1, _ false, xltoptobottom
end Sub
Reply With Quote
  #2 (permalink)  
Old 08-05-04, 09:43
MikeTheBike MikeTheBike is offline
Registered User
 
Join Date: Apr 2004
Location: Derbyshire, UK
Posts: 714
Selecting Sort Rows

Hi

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.

Code:
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
        Loop
        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

MTB
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On