Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 2nd, 2003, 11:15 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default move rows to top with cells in columnA filled RED

Hi people

Do you have the VB code that can move the rows to the top with cells background filled in RED color in column (then follow by rows with any cells in column A not being filled in RED color) ?

Alternatively, it will be fine if you have a code that move the rows to the top with any cells in column A that have the font in RED.

Thank for your help in advance.

Reply With Quote
  #2 (permalink)  
Old December 2nd, 2003, 11:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: London, , United Kingdom.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You'll need something like this
Code:
Private Sub ColorSort()
Dim x As Integer, iInsertedRows As Integer

x = Range("A1").End(xlDown).Row

For x = x To 1 Step -1
    If Cells(x, 1).Interior.ColorIndex = 3 Then '3 is standard red color
        Rows(x).Cut
        Rows("1:1").Insert Shift:=xlDown 'paste the cut row back as row 1
        x = x + 1 'we've just moved everything down a row
        iInsertedRows = iInsertedRows + 1
        If iInsertedRows = x Then Exit For 'we don't need to sort the ones we put there
    End If
Next
End Sub
It's basic, but it works. There's plenty of scope for for customisation ;)

HTH Chris



There are two secrets to success in this world:
1. Never tell everything you know
Reply With Quote
  #3 (permalink)  
Old December 2nd, 2003, 11:51 AM
Registered User
 
Join Date: Nov 2003
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Chris,

you are fantastic!
Thank you so much!

Reply With Quote
Reply


Thread Tools
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to move rows in a table bucky483 Javascript How-To 10 March 27th, 2017 12:57 AM
Move Datagrid rows michael29 ASP.NET 1.0 and 1.1 Professional 1 April 24th, 2007 05:31 PM
delete all empty cells and move them to the left crmpicco Excel VBA 1 May 6th, 2005 05:47 AM
Getting the Top 5 Rows from a datatable flyin General .NET 9 June 14th, 2004 08:36 AM
remove rows to Sheet2 (cells in columnA filled RED alienscript Excel VBA 1 December 2nd, 2003 11:53 AM



All times are GMT -4. The time now is 11:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.