+ Reply to Thread
Results 1 to 11 of 11

Auto delete a line?

  1. #1
    Registered User
    Join Date
    03-26-2008
    Posts
    15

    Auto delete a line?

    How would you make a macro that would delete the line if a field in that line say for example K1:K100 had "XX" or "XXX" in it?

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Do a quick search on forum for examples or see link

    http://www.rondebruin.nl/delete.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    Hi schlepers,

    A quick and easy way of doing this would be to loop all the cells, check the values and then delete if need be.

    This code should do the job:

    Please Login or Register  to view this content.
    I havnt had chance to check this code so look out for a glitch or a little tweak, but the basic idea is there

  4. #4
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    thx. Let me check them out.

    j--

  5. #5
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    How would you do it with:

    with this if you want to fill in the Firstrow and let the code find the Lastrow in the column.

    Please Login or Register  to view this content.
    Where it automatically figures out the last line instead of the range value?
    Last edited by VBA Noob; 06-12-2008 at 03:18 PM.

  6. #6
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    yea you could do that or you could write a loop to check if the active cell is the last in a list but if the list goes into its 1000's a loop could take a while

  7. #7
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    I wanted to add this into a sorting Macro. I can't seem to make it work, I'm doing it wrong?

  8. #8
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    schlepers,

    Please read forum rules below. All code needs to be wrapped as I did on your first post

    VBA Noob

  9. #9
    Forum Contributor Stuie's Avatar
    Join Date
    09-17-2006
    Location
    Suffolk, UK
    MS-Off Ver
    Excel 2003/2007
    Posts
    432
    one peice of the code that needs correcting would be the

    Please Login or Register  to view this content.
    when using Or/And in IF block you need to re compair like so:
    (i have highlighted the change)

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 06-12-2008 at 04:23 PM.

  10. #10
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    I wanted to add this into a sorting Macro. I can't seem to make it work, I'm doing it wrong?

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    03-26-2008
    Posts
    15
    I gete an error when I run above for some reason??

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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