View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Cato Larsen Cato Larsen is offline
external usenet poster
 
Posts: 10
Default Moving rows with grey background color to bottom (2003)

Hey!
I've gotten a request from a user to program a VB macro that moves all rows
in a spreadsheet to the bottom if it contains a color (rgb(120,120,120))
I've been google'ing like nuts, but I've yet to find a solution that fits
the task.

As I've set it up right now its basicly something like this:

' Do a quick loop to find the bottom:
Do
iCounter = iCounter + 1
Loop Untill Cells(iCounter, 1).Value = ""

' Copy bottom interget into correct variable
iBottom = iCounter

' Set iCounter to first row below header.
iCounter = 2

Pseudocode for what I need:
loop while iCounter < iBottom
if currentRow.BackgroundColor = Grey
swap currentRow with Row(iBottom)
iBottom - 1
else iCounter + 1
end if
loop end

Can anyone help me out?
--
Cato Larsen
HelpDesk Monkey