Search : in
By :

Delete All Rows Except.....

Last answer on Apr 19, 2009 9:09:03 am BST fawchert, on Nov 13, 2008 3:32:04 am GMT 
 Report this message to moderators

Hello,

I have a questions that i could not find the answer yet.
I'm also new in macro VBA programming.
The question is, I need to delete all rows in excel except the last row and any rows that have this word: "Blocked".
Anyone with brilliant idea?
Thanks :)

Configuration: Windows XP
Firefox 3.0.3

Best answers for « Delete All Rows Except..... » in :
How to know who blocked/deleted you on MSN ShowHow to know who blocked/deleted you on MSN There are many websites that claim to be able to confirm if a contact on your list has blocked you or not. These so-called block checkers do this by detecting the public status of the user who...
[Sed] Delete one or more lines from a file Show[Sed] Delete one or more lines from a file Removing one (or several) line (s) of a file Syntax: sed '{[/]||[/]}d' sed '{[/][,][/]d' /.../=delimiters n = line number...
How to restore deleted files ShowHow to restore deleted files Download a recovery tool There are easy and effective recovery tools available for download on the web and some have the major advantage of being free. Zero Assumption Recovery Download Link: http://www.z-a...

1

helpmeout, on Nov 13, 2008 9:29:43 am GMT

Hey there,

well i will provide you with a link where you will be able to search for what you are willing to do:

http://office.microsoft.com/...

hope it will help you

Reply to helpmeout

2

aquarelle, on Nov 13, 2008 4:20:45 pm GMT

Hi,
Is the word "blocked" always written in the same column ? If it is the case what column ?
See you "Pour trouver une solution � ses probl�mes, il faut s'en donner la peine."

Reply to aquarelle

3

fawchert, on Nov 13, 2008 11:39:29 pm GMT

Thanks for your respond guys..
no, the word "Blocked" was not always in the same column. I'll received this excel file every week from the users but the format was different. Sometimes could be in column L, sometimes could be M.
I just want this column, remove the others.
Thanks

Reply to fawchert

4

 aquarelle, on Nov 14, 2008 6:51:38 pm GMT

Hello,
Hope this will work according to your demand :

Sub testDelete()

Dim plage As Range
Dim numlig As Integer
Dim numcol As Integer
Dim cpt As Integer
Dim nblig As Integer
Dim nbcol As Integer

Set plage = Range("A65536").End(xlUp).CurrentRegion
nblig = plage.Rows.Count
nbcol = plage.Columns.Count


For numlig = nblig To 1 Step -1
   cpt = 0 

   For numcol = 1 To nbcol
      If plage.Rows(numlig).Columns(numcol) = "Blocked" Then
          cpt = cpt + 1
      End If
   Next numcol

   If cpt = 0 Then
    Rows(numlig).delete
   End If

Next numlig
End Sub



Best regards "Pour trouver une solution � ses probl�mes, il faut s'en donner la peine."

Reply to aquarelle