+ Reply to Thread
Results 1 to 5 of 5

sort and delete

  1. #1
    Forum Contributor
    Join Date
    01-14-2004
    Location
    India
    MS-Off Ver
    365
    Posts
    264

    sort and delete

    Hi everyone
    Someone please helpme......
    I have an excel file with some data and the column "K" is to enter the date of payment.
    I want the data to be sorted by column "K" and delete the rows if it has a data in column "K"

    This is to find out the rows with no date in "K"

    I need a macro to run

    Thanks in Advance
    Toms

  2. #2
    Dave Peterson
    Guest

    Re: sort and delete

    How about an alternative.

    Select your range (all of it or just column K).

    Then use Data|Filter|Autofilter

    You can use the dropdown arrow in column K to show just the blanks.

    Or you can use that dropdown to show all the non-blanks (and delete those
    visible rows if you really want).

    If you need a macro, record one when you do it manually.

    I really like keeping the data and hiding/showing the data.



    SMILE wrote:
    >
    > Hi everyone
    > Someone please helpme......
    > I have an excel file with some data and the column "K" is to enter the
    > date of payment.
    > I want the data to be sorted by column "K" and delete the rows if it
    > has a data in column "K"
    >
    > This is to find out the rows with no date in "K"
    >
    > I need a macro to run
    >
    > Thanks in Advance
    > Toms
    >
    > --
    > SMILE
    > ------------------------------------------------------------------------
    > SMILE's Profile: http://www.excelforum.com/member.php...fo&userid=4880
    > View this thread: http://www.excelforum.com/showthread...hreadid=390143


    --

    Dave Peterson

  3. #3
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    While I'm sure a macro can be built to do what you ask, have you looked at AutoFilter? You can apply the filter to show only rows with blanks in Col. K (or only non-blanks) which you can then delete enmasse or copy to another area, etc.

    Just a thought....
    Bruce
    The older I get, the better I used to be.
    USA

  4. #4
    Forum Contributor
    Join Date
    01-14-2004
    Location
    India
    MS-Off Ver
    365
    Posts
    264
    Hi
    I do agree the autofilter will do.. but in my case I do not want the autofilter.. I really need a macro to run. I cannot record a new macro doing it mannual becoz each time the number of rows will be different. Hope someone can help me.....
    Thanks

  5. #5
    Dave Peterson
    Guest

    Re: sort and delete

    I recorded a macro that selected column K, did the autofilter, showed the
    non-blank cells and deleted those visible rows and removed the autofilter.

    Option Explicit
    Sub Macro1()
    Columns("K:K").Select
    Selection.AutoFilter
    Selection.AutoFilter Field:=1, Criteria1:="<>"
    Range("K2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.EntireRow.Delete
    Range("K1").Select
    Selection.AutoFilter
    End Sub

    It seemed to work fine no matter the number of rows.

    SMILE wrote:
    >
    > Hi
    > I do agree the autofilter will do.. but in my case I do not want the
    > autofilter.. I really need a macro to run. I cannot record a new macro
    > doing it mannual becoz each time the number of rows will be different.
    > Hope someone can help me.....
    > Thanks
    >
    > --
    > SMILE
    > ------------------------------------------------------------------------
    > SMILE's Profile: http://www.excelforum.com/member.php...fo&userid=4880
    > View this thread: http://www.excelforum.com/showthread...hreadid=390143


    --

    Dave Peterson

+ 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