+ Reply to Thread
Results 1 to 10 of 10

Delete rows based on fill color

Hybrid View

schueyisking Delete rows based on fill... 08-21-2008, 09:57 AM
MickG Hi, In simple terms this... 08-21-2008, 10:43 AM
schueyisking hi , thanks for your... 08-21-2008, 11:18 AM
MickG Hi, Have a read of this , it... 08-21-2008, 11:28 AM
schueyisking hi mick, certainly... 08-21-2008, 11:43 AM
SOS Hi schueyisking, That code... 08-21-2008, 12:10 PM
MickG Hi, The reason it's not... 08-21-2008, 12:15 PM
schueyisking Oooooh right I see. Yeh I... 08-22-2008, 04:48 AM
schueyisking awesome it works fine now,the... 08-22-2008, 04:50 AM
schueyisking Actually i've discovered a... 08-22-2008, 05:54 AM
  1. #1
    Registered User
    Join Date
    07-30-2008
    Location
    UK
    Posts
    52
    hi mick,

    certainly learning something new today!

    i created the command button, followed the instructions, ran it, but it still didn't seem to do anything.
    i've attached the file i was testing it on.
    as you can see i just made some rows up to column H, with some that are red, and ones with no fill, in the hope that when i pressed the button, rows 4,5, and 9 would dissapear.

    im obviously doing something completely wrong, would appreciate your input on it.

    cheers.
    Attached Files Attached Files

  2. #2
    Forum Contributor SOS's Avatar
    Join Date
    01-26-2004
    Location
    Glasgow, Scotland
    MS-Off Ver
    Excel 2003
    Posts
    327
    Hi schueyisking,

    That code would work if the cells in column A had data in them. The reason it doesn't work is that the line

    Last = Range("A" & Rows.Count).End(xlUp).Row
    ends up as being 1 because that line is looking for data in Column A.

    If, however, you selected all the cells you need in Column A and then run this code it should do what you want:

    Private Sub CommandButton1_Click()
        For i = Selection.Rows.Count To 1 Step -1
        If Range("A" & i).Interior.ColorIndex = xlNone Then
           Range("A" & i).EntireRow.Delete
        End If
       Next i
    End Sub
    Last edited by SOS; 08-21-2008 at 12:32 PM.
    Hope this helps

    Seamus

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650
    Hi, The reason it's not working is because you have no Data in column "A".
    If you want it to work that way change the Variable "Last" to a row number like this:-
    Last = 50 (Or Whatever)
    NB I've just seen you already got the solution fron SOS!!
    Regards Mick

  4. #4
    Registered User
    Join Date
    07-30-2008
    Location
    UK
    Posts
    52
    Oooooh right I see.

    Yeh I would actually be using this on rows with data, so the original code will work then, sorry I didn't realise it was dependent on looking for information in the cells (I can't read code at all obviously).

    Thanks, i'll give it a go now, should work.

    much appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro: changing cell color based on count in cell
    By Vbort44 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-08-2008, 07:28 PM
  2. create a simple macro that changes fill color
    By Niclas in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-17-2008, 05:13 PM
  3. Delete rows based on values from worksheet
    By dc6463 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2008, 10:16 AM
  4. color fill rows?
    By tgs23lax in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2007, 03:08 PM
  5. Replies: 2
    Last Post: 03-01-2007, 04:51 PM

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