+ Reply to Thread
Results 1 to 10 of 10

Macro for deleting rows

  1. #1
    Registered User
    Join Date
    10-08-2008
    Location
    Spain
    Posts
    8

    Macro for deleting rows

    I have an Excel database “tg11” with 720 names and 12 columns in worksheet “Mem”. It is updated daily. It is also saved in CSV format for a mail program. We now need to save it for two mailing lists. One list will contain all entries having “Yes” in col F “tg11_yes”. The second list will contain all entries not having “Yes” in col F “tg11_online”.
    Stumped on how to delete rows having a blank cell in Col F, then reopening the database “tg11” to delete rows having “Yes” in col F.
    Thanks
    Gilbert

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for deleting rows

    This is what the AUTOFILTER was designed for. Your macro should:

    1) Turn on the AutoFilter
    2) Filter column F for Yes
    3) Copy the visible data to a brand new workbook
    4) Save the workbook to the appropriate location/name, and close it

    5) Filter column again by Custom: Does not equal: Yes
    6) Copy the visible data to a brand new workbook
    7) Save the workbook to the appropriate location/name, and close it
    8) Copy the main sheet to a new destructible workbook


    You should be able to turn on the macro recorder, record you doing that whole process once by hand, then the macro will be almost ready to use. Try it.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro for deleting rows

    Please Login or Register  to view this content.
    and

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-08-2008
    Location
    Spain
    Posts
    8

    Re: Macro for deleting rows

    The Autofilter did not work. Saved the filtered list as another workbook but when opened I could select Autofilter - All to see the whole lot. I am using Office 2003.

    Bob. There are 705 rows including a header row. It deleted all the rows with a blank in Col F, except for the last 14 entries.

  5. #5
    Registered User
    Join Date
    10-08-2008
    Location
    Spain
    Posts
    8

    Re: Macro for deleting rows

    Bob. The second one to delete all the rows with Yes did work, albeit slowly.

    Tks

  6. #6
    Registered User
    Join Date
    10-08-2008
    Location
    Spain
    Posts
    8

    Re: Macro for deleting rows

    Jerry. Apologies I missed the "Copy". Thats fine
    Tks

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for deleting rows

    If you record that into a macro, post the resulting code here and we can help you clean it up into a permanent flexible macro.

  8. #8
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro for deleting rows

    You can speed it up by turning screenupdating off at the start.

  9. #9
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro for deleting rows

    Quote Originally Posted by Galceran View Post
    The Autofilter did not work. Saved the filtered list as another workbook but when opened I could select Autofilter - All to see the whole lot. I am using Office 2003.

    Bob. There are 705 rows including a header row. It deleted all the rows with a blank in Col F, except for the last 14 entries.
    Was that because the last 14 rows wer all blank in F but had data in other columns?

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Macro for deleting rows

    Post your resulting "code" so we can see what you did, I'm sure something will pop out to us.

+ 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