+ Reply to Thread
Results 1 to 11 of 11

delete rows

  1. #1
    js
    Guest

    delete rows

    Hi,

    I have a excel file like this:
    id name
    1 ll1
    2 ll2
    abc xxxxxxxxxxxxxx
    10 ll3

    23 ll4

    my job is to remove the empty line or the id column is not numeric, I manual
    did it now. I have lot's row. is it possible to do using VBA? just check id
    is numeric or empty, then delete? I'm new to excel, please help. Thanks.



  2. #2
    Norman Jones
    Guest

    Re: delete rows

    Hi JS,

    > just check id is numeric or empty, then delete?


    Try:

    '=============>>
    Public Sub Tester()
    With Columns(1)
    .SpecialCells(xlCellTypeConstants, xlNumbers). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "js" <js@[email protected]> wrote in message
    news:[email protected]...
    > Hi,
    >
    > I have a excel file like this:
    > id name
    > 1 ll1
    > 2 ll2
    > abc xxxxxxxxxxxxxx
    > 10 ll3
    >
    > 23 ll4
    >
    > my job is to remove the empty line or the id column is not numeric, I
    > manual did it now. I have lot's row. is it possible to do using VBA? just
    > check id is numeric or empty, then delete? I'm new to excel, please help.
    > Thanks.
    >
    >




  3. #3
    js
    Guest

    Re: delete rows

    Thanks Norman...

    How to run? I'm new to excel.


    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi JS,
    >
    >> just check id is numeric or empty, then delete?

    >
    > Try:
    >
    > '=============>>
    > Public Sub Tester()
    > With Columns(1)
    > .SpecialCells(xlCellTypeConstants, xlNumbers). _
    > EntireRow.Delete
    > .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    > End With
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "js" <js@[email protected]> wrote in message
    > news:[email protected]...
    >> Hi,
    >>
    >> I have a excel file like this:
    >> id name
    >> 1 ll1
    >> 2 ll2
    >> abc xxxxxxxxxxxxxx
    >> 10 ll3
    >>
    >> 23 ll4
    >>
    >> my job is to remove the empty line or the id column is not numeric, I
    >> manual did it now. I have lot's row. is it possible to do using VBA? just
    >> check id is numeric or empty, then delete? I'm new to excel, please help.
    >> Thanks.
    >>
    >>

    >
    >




  4. #4
    js
    Guest

    Re: delete rows

    Hi Norman,

    the condition is not numeric,

    >>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?


    How to add it?



    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi JS,
    >
    >> just check id is numeric or empty, then delete?

    >
    > Try:
    >
    > '=============>>
    > Public Sub Tester()
    > With Columns(1)
    > .SpecialCells(xlCellTypeConstants, xlNumbers). _
    > EntireRow.Delete
    > .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    > End With
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "js" <js@[email protected]> wrote in message
    > news:[email protected]...
    >> Hi,
    >>
    >> I have a excel file like this:
    >> id name
    >> 1 ll1
    >> 2 ll2
    >> abc xxxxxxxxxxxxxx
    >> 10 ll3
    >>
    >> 23 ll4
    >>
    >> my job is to remove the empty line or the id column is not numeric, I
    >> manual did it now. I have lot's row. is it possible to do using VBA? just
    >> check id is numeric or empty, then delete? I'm new to excel, please help.
    >> Thanks.
    >>
    >>

    >
    >




  5. #5
    Norman Jones
    Guest

    Re: delete rows

    Hi JS,

    > the condition is not numeric,
    >
    >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?

    >
    > How to add it?


    In that case, try this revised version:

    '=============>>
    Public Sub TesterA()
    With Columns(1)
    .SpecialCells(xlCellTypeConstants, xlTextValues). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    End Sub
    '<<=============

    As you are new to macros, you may wish to visit David McRitchie's 'Getting
    Started With Macros And User Defined Functions' at:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    You may also wish to look at David's tutorial page:

    http://www.mvps.org/dmcritchie/excel....htm#tutorials

    To run the suggested code, try:

    Copy the code
    Alt-F11 to open the VBA editor
    Menus | Insert | Module
    Paste the code
    Alt-F11 to return to Excel
    Select the worksheet of interest
    Alt-F8 to open the Macro Dialog
    Select the macro in the dropdown window
    Run

    I suggest that you try the code on a copy of your data to verify that the
    code achieves your intended results.


    ---
    Regards,
    Norman


    "js" <js@[email protected]> wrote in message
    news:%[email protected]...
    > Hi Norman,
    >
    > the condition is not numeric,
    >
    >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?

    >
    > How to add it?
    >
    >
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi JS,
    >>
    >>> just check id is numeric or empty, then delete?

    >>
    >> Try:
    >>
    >> '=============>>
    >> Public Sub Tester()
    >> With Columns(1)
    >> .SpecialCells(xlCellTypeConstants, xlNumbers). _
    >> EntireRow.Delete
    >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> End With
    >> End Sub
    >> '<<=============
    >>
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >> "js" <js@[email protected]> wrote in message
    >> news:[email protected]...
    >>> Hi,
    >>>
    >>> I have a excel file like this:
    >>> id name
    >>> 1 ll1
    >>> 2 ll2
    >>> abc xxxxxxxxxxxxxx
    >>> 10 ll3
    >>>
    >>> 23 ll4
    >>>
    >>> my job is to remove the empty line or the id column is not numeric, I
    >>> manual did it now. I have lot's row. is it possible to do using VBA?
    >>> just check id is numeric or empty, then delete? I'm new to excel, please
    >>> help. Thanks.
    >>>
    >>>

    >>
    >>

    >
    >




  6. #6
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    H Norman,
    This code of yours:
    '=============>>
    Public Sub TextAndBlanks()
    With Columns(1)
    .SpecialCells(xlCellTypeConstants, xlTextValues). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    End Sub
    '<<=============
    Will delete rows with all combinations of text and spaces IE:
    a
    1a
    1 a
    a1
    a 1
    The other code however for the numbers
    '=============>>
    Public Sub NumbersAndBlanks()
    With Columns(1)
    .SpecialCells(xlCellTypeConstants, xlNumbers). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    End Sub
    '<<=============
    Will only delete rows if the entire string is numbers or spaces.
    Not when there is a combination IE:
    1a
    a1
    a 1
    1 aa

    Why wouldn't they both do the same thing, one for numbers, one for text?
    Dave
    Quote Originally Posted by Norman Jones
    Hi JS,

    > the condition is not numeric,
    >
    >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?

    >
    > How to add it?


    In that case, try this revised version:

    '=============>>
    Public Sub TesterA()
    With Columns(1)
    .SpecialCells(xlCellTypeConstants, xlTextValues). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    End Sub
    '<<=============

    As you are new to macros, you may wish to visit David McRitchie's 'Getting
    Started With Macros And User Defined Functions' at:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    You may also wish to look at David's tutorial page:

    http://www.mvps.org/dmcritchie/excel....htm#tutorials

    To run the suggested code, try:

    Copy the code
    Alt-F11 to open the VBA editor
    Menus | Insert | Module
    Paste the code
    Alt-F11 to return to Excel
    Select the worksheet of interest
    Alt-F8 to open the Macro Dialog
    Select the macro in the dropdown window
    Run

    I suggest that you try the code on a copy of your data to verify that the
    code achieves your intended results.


    ---
    Regards,
    Norman


    "js" <js@[email protected]> wrote in message
    news:%[email protected]...
    > Hi Norman,
    >
    > the condition is not numeric,
    >
    >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?

    >
    > How to add it?
    >
    >
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi JS,
    >>
    >>> just check id is numeric or empty, then delete?

    >>
    >> Try:
    >>
    >> '=============>>
    >> Public Sub Tester()
    >> With Columns(1)
    >> .SpecialCells(xlCellTypeConstants, xlNumbers). _
    >> EntireRow.Delete
    >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> End With
    >> End Sub
    >> '<<=============
    >>
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >> "js" <js@[email protected]> wrote in message
    >> news:[email protected]...
    >>> Hi,
    >>>
    >>> I have a excel file like this:
    >>> id name
    >>> 1 ll1
    >>> 2 ll2
    >>> abc xxxxxxxxxxxxxx
    >>> 10 ll3
    >>>
    >>> 23 ll4
    >>>
    >>> my job is to remove the empty line or the id column is not numeric, I
    >>> manual did it now. I have lot's row. is it possible to do using VBA?
    >>> just check id is numeric or empty, then delete? I'm new to excel, please
    >>> help. Thanks.
    >>>
    >>>

    >>
    >>

    >
    >
    Thx
    Dave
    "The game is afoot Watson"

  7. #7
    Norman Jones
    Guest

    Re: delete rows

    Hi Dave,

    The SpecialCells method regards combinations of spaces and alphanumeric
    characters as text constants. Therefore, as you observe, the code:

    > SpecialCells(xlCellTypeConstants, xlTextValues). _
    > EntireRow.Delete


    will delete all alphanumeric strings, including those with embedded spaces.

    Number constants cannot include spaces, so the code:

    > SpecialCells(xlCellTypeConstants, xlNumbers). _
    > EntireRow.Delete


    will ignore any constant containing embedded spaces and only delete numeric
    constants.

    In both cases, the code:

    > SpecialCells(xlCellTypeBlanks).EntireRow.Delete


    relates only to empty (blank) cells. Empty cells are not recognised as
    either text or number constants: hence the use of this latter code line in
    both instances.


    ---
    Regards,
    Norman



    "Desert Piranha"
    <[email protected]> wrote in
    message news:[email protected]...
    >
    > H Norman,
    > This code of yours:
    > '=============>>
    > Public Sub TextAndBlanks()
    > With Columns(1)
    > SpecialCells(xlCellTypeConstants, xlTextValues). _
    > EntireRow.Delete
    > SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    > End With
    > End Sub
    > '<<=============
    > Will delete rows with all combinations of text and spaces IE:
    > a
    > 1a
    > 1 a
    > a1
    > a 1
    > The other code however for the numbers
    > '=============>>
    > Public Sub NumbersAndBlanks()
    > With Columns(1)
    > SpecialCells(xlCellTypeConstants, xlNumbers). _
    > EntireRow.Delete
    > SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    > End With
    > End Sub
    > '<<=============
    > Will only delete rows if the entire string is numbers or spaces.
    > Not when there is a combination IE:
    > 1a
    > a1
    > a 1
    > 1 aa
    >
    > Why wouldn't they both do the same thing, one for numbers, one for
    > text?
    > Dave
    > Norman Jones Wrote:
    >> Hi JS,
    >>
    >> > the condition is not numeric,
    >> >
    >> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >> >
    >> > How to add it?

    >>
    >> In that case, try this revised version:
    >>
    >> '=============>>
    >> Public Sub TesterA()
    >> With Columns(1)
    >> .SpecialCells(xlCellTypeConstants, xlTextValues). _
    >> EntireRow.Delete
    >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> End With
    >> End Sub
    >> '<<=============
    >>
    >> As you are new to macros, you may wish to visit David McRitchie's
    >> 'Getting
    >> Started With Macros And User Defined Functions' at:
    >>
    >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>
    >> You may also wish to look at David's tutorial page:
    >>
    >> http://www.mvps.org/dmcritchie/excel....htm#tutorials
    >>
    >> To run the suggested code, try:
    >>
    >> Copy the code
    >> Alt-F11 to open the VBA editor
    >> Menus | Insert | Module
    >> Paste the code
    >> Alt-F11 to return to Excel
    >> Select the worksheet of interest
    >> Alt-F8 to open the Macro Dialog
    >> Select the macro in the dropdown window
    >> Run
    >>
    >> I suggest that you try the code on a copy of your data to verify that
    >> the
    >> code achieves your intended results.
    >>
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >> "js" <js@[email protected]> wrote in message
    >> news:%[email protected]...
    >> > Hi Norman,
    >> >
    >> > the condition is not numeric,
    >> >
    >> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >> >
    >> > How to add it?
    >> >
    >> >
    >> >
    >> > "Norman Jones" <[email protected]> wrote in message
    >> > news:[email protected]...
    >> >> Hi JS,
    >> >>
    >> >>> just check id is numeric or empty, then delete?
    >> >>
    >> >> Try:
    >> >>
    >> >> '=============>>
    >> >> Public Sub Tester()
    >> >> With Columns(1)
    >> >> .SpecialCells(xlCellTypeConstants, xlNumbers). _
    >> >> EntireRow.Delete
    >> >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> >> End With
    >> >> End Sub
    >> >> '<<=============
    >> >>
    >> >>
    >> >> ---
    >> >> Regards,
    >> >> Norman
    >> >>
    >> >>
    >> >> "js" <js@[email protected]> wrote in message
    >> >> news:[email protected]...
    >> >>> Hi,
    >> >>>
    >> >>> I have a excel file like this:
    >> >>> id name
    >> >>> 1 ll1
    >> >>> 2 ll2
    >> >>> abc xxxxxxxxxxxxxx
    >> >>> 10 ll3
    >> >>>
    >> >>> 23 ll4
    >> >>>
    >> >>> my job is to remove the empty line or the id column is not numeric,

    >> I
    >> >>> manual did it now. I have lot's row. is it possible to do using

    >> VBA?
    >> >>> just check id is numeric or empty, then delete? I'm new to excel,

    >> please
    >> >>> help. Thanks.
    >> >>>
    >> >>>
    >> >>
    >> >>
    >> >
    >> >

    >
    >
    > --
    > Desert Piranha
    >
    >
    > ------------------------------------------------------------------------
    > Desert Piranha's Profile:
    > http://www.excelforum.com/member.php...o&userid=28934
    > View this thread: http://www.excelforum.com/showthread...hreadid=493213
    >




  8. #8
    js
    Guest

    Re: delete rows

    Thanks Norman Jones...

    "Norman Jones" <[email protected]> wrote in message > Hi Dave,
    >




  9. #9
    js
    Guest

    Re: delete rows

    how to add logic to it so it won't delte rows before 4? Thanks.

    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Dave,
    >
    > The SpecialCells method regards combinations of spaces and alphanumeric
    > characters as text constants. Therefore, as you observe, the code:
    >
    >> SpecialCells(xlCellTypeConstants, xlTextValues). _
    >> EntireRow.Delete

    >
    > will delete all alphanumeric strings, including those with embedded
    > spaces.
    >
    > Number constants cannot include spaces, so the code:
    >
    >> SpecialCells(xlCellTypeConstants, xlNumbers). _
    >> EntireRow.Delete

    >
    > will ignore any constant containing embedded spaces and only delete
    > numeric constants.
    >
    > In both cases, the code:
    >
    >> SpecialCells(xlCellTypeBlanks).EntireRow.Delete

    >
    > relates only to empty (blank) cells. Empty cells are not recognised as
    > either text or number constants: hence the use of this latter code line in
    > both instances.
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Desert Piranha"
    > <[email protected]> wrote in
    > message
    > news:[email protected]...
    >>
    >> H Norman,
    >> This code of yours:
    >> '=============>>
    >> Public Sub TextAndBlanks()
    >> With Columns(1)
    >> SpecialCells(xlCellTypeConstants, xlTextValues). _
    >> EntireRow.Delete
    >> SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> End With
    >> End Sub
    >> '<<=============
    >> Will delete rows with all combinations of text and spaces IE:
    >> a
    >> 1a
    >> 1 a
    >> a1
    >> a 1
    >> The other code however for the numbers
    >> '=============>>
    >> Public Sub NumbersAndBlanks()
    >> With Columns(1)
    >> SpecialCells(xlCellTypeConstants, xlNumbers). _
    >> EntireRow.Delete
    >> SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >> End With
    >> End Sub
    >> '<<=============
    >> Will only delete rows if the entire string is numbers or spaces.
    >> Not when there is a combination IE:
    >> 1a
    >> a1
    >> a 1
    >> 1 aa
    >>
    >> Why wouldn't they both do the same thing, one for numbers, one for
    >> text?
    >> Dave
    >> Norman Jones Wrote:
    >>> Hi JS,
    >>>
    >>> > the condition is not numeric,
    >>> >
    >>> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >>> >
    >>> > How to add it?
    >>>
    >>> In that case, try this revised version:
    >>>
    >>> '=============>>
    >>> Public Sub TesterA()
    >>> With Columns(1)
    >>> .SpecialCells(xlCellTypeConstants, xlTextValues). _
    >>> EntireRow.Delete
    >>> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>> End With
    >>> End Sub
    >>> '<<=============
    >>>
    >>> As you are new to macros, you may wish to visit David McRitchie's
    >>> 'Getting
    >>> Started With Macros And User Defined Functions' at:
    >>>
    >>> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>>
    >>> You may also wish to look at David's tutorial page:
    >>>
    >>> http://www.mvps.org/dmcritchie/excel....htm#tutorials
    >>>
    >>> To run the suggested code, try:
    >>>
    >>> Copy the code
    >>> Alt-F11 to open the VBA editor
    >>> Menus | Insert | Module
    >>> Paste the code
    >>> Alt-F11 to return to Excel
    >>> Select the worksheet of interest
    >>> Alt-F8 to open the Macro Dialog
    >>> Select the macro in the dropdown window
    >>> Run
    >>>
    >>> I suggest that you try the code on a copy of your data to verify that
    >>> the
    >>> code achieves your intended results.
    >>>
    >>>
    >>> ---
    >>> Regards,
    >>> Norman
    >>>
    >>>
    >>> "js" <js@[email protected]> wrote in message
    >>> news:%[email protected]...
    >>> > Hi Norman,
    >>> >
    >>> > the condition is not numeric,
    >>> >
    >>> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >>> >
    >>> > How to add it?
    >>> >
    >>> >
    >>> >
    >>> > "Norman Jones" <[email protected]> wrote in message
    >>> > news:[email protected]...
    >>> >> Hi JS,
    >>> >>
    >>> >>> just check id is numeric or empty, then delete?
    >>> >>
    >>> >> Try:
    >>> >>
    >>> >> '=============>>
    >>> >> Public Sub Tester()
    >>> >> With Columns(1)
    >>> >> .SpecialCells(xlCellTypeConstants, xlNumbers). _
    >>> >> EntireRow.Delete
    >>> >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>> >> End With
    >>> >> End Sub
    >>> >> '<<=============
    >>> >>
    >>> >>
    >>> >> ---
    >>> >> Regards,
    >>> >> Norman
    >>> >>
    >>> >>
    >>> >> "js" <js@[email protected]> wrote in message
    >>> >> news:[email protected]...
    >>> >>> Hi,
    >>> >>>
    >>> >>> I have a excel file like this:
    >>> >>> id name
    >>> >>> 1 ll1
    >>> >>> 2 ll2
    >>> >>> abc xxxxxxxxxxxxxx
    >>> >>> 10 ll3
    >>> >>>
    >>> >>> 23 ll4
    >>> >>>
    >>> >>> my job is to remove the empty line or the id column is not numeric,
    >>> I
    >>> >>> manual did it now. I have lot's row. is it possible to do using
    >>> VBA?
    >>> >>> just check id is numeric or empty, then delete? I'm new to excel,
    >>> please
    >>> >>> help. Thanks.
    >>> >>>
    >>> >>>
    >>> >>
    >>> >>
    >>> >
    >>> >

    >>
    >>
    >> --
    >> Desert Piranha
    >>
    >>
    >> ------------------------------------------------------------------------
    >> Desert Piranha's Profile:
    >> http://www.excelforum.com/member.php...o&userid=28934
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=493213
    >>

    >
    >




  10. #10
    Norman Jones
    Guest

    Re: delete rows

    Hi JS,

    Try:

    '=============>>
    Public Sub TesterA()
    Dim rng As Range
    Dim LRow As Long

    LRow = Cells(Rows.Count, "A").Row

    Set rng = Range("A4:A" & LRow)

    With rng
    On Error Resume Next
    .SpecialCells(xlCellTypeConstants, xlTextValues). _
    EntireRow.Delete
    .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0
    End With
    End Sub
    '<<=============


    ---
    Regards,
    Norman



    "js" <js@[email protected]> wrote in message
    news:[email protected]...
    > how to add logic to it so it won't delte rows before 4? Thanks.
    >
    > "Norman Jones" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi Dave,
    >>
    >> The SpecialCells method regards combinations of spaces and alphanumeric
    >> characters as text constants. Therefore, as you observe, the code:
    >>
    >>> SpecialCells(xlCellTypeConstants, xlTextValues). _
    >>> EntireRow.Delete

    >>
    >> will delete all alphanumeric strings, including those with embedded
    >> spaces.
    >>
    >> Number constants cannot include spaces, so the code:
    >>
    >>> SpecialCells(xlCellTypeConstants, xlNumbers). _
    >>> EntireRow.Delete

    >>
    >> will ignore any constant containing embedded spaces and only delete
    >> numeric constants.
    >>
    >> In both cases, the code:
    >>
    >>> SpecialCells(xlCellTypeBlanks).EntireRow.Delete

    >>
    >> relates only to empty (blank) cells. Empty cells are not recognised as
    >> either text or number constants: hence the use of this latter code line
    >> in both instances.
    >>
    >>
    >> ---
    >> Regards,
    >> Norman
    >>
    >>
    >>
    >> "Desert Piranha"
    >> <[email protected]> wrote in
    >> message
    >> news:[email protected]...
    >>>
    >>> H Norman,
    >>> This code of yours:
    >>> '=============>>
    >>> Public Sub TextAndBlanks()
    >>> With Columns(1)
    >>> SpecialCells(xlCellTypeConstants, xlTextValues). _
    >>> EntireRow.Delete
    >>> SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>> End With
    >>> End Sub
    >>> '<<=============
    >>> Will delete rows with all combinations of text and spaces IE:
    >>> a
    >>> 1a
    >>> 1 a
    >>> a1
    >>> a 1
    >>> The other code however for the numbers
    >>> '=============>>
    >>> Public Sub NumbersAndBlanks()
    >>> With Columns(1)
    >>> SpecialCells(xlCellTypeConstants, xlNumbers). _
    >>> EntireRow.Delete
    >>> SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>> End With
    >>> End Sub
    >>> '<<=============
    >>> Will only delete rows if the entire string is numbers or spaces.
    >>> Not when there is a combination IE:
    >>> 1a
    >>> a1
    >>> a 1
    >>> 1 aa
    >>>
    >>> Why wouldn't they both do the same thing, one for numbers, one for
    >>> text?
    >>> Dave
    >>> Norman Jones Wrote:
    >>>> Hi JS,
    >>>>
    >>>> > the condition is not numeric,
    >>>> >
    >>>> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >>>> >
    >>>> > How to add it?
    >>>>
    >>>> In that case, try this revised version:
    >>>>
    >>>> '=============>>
    >>>> Public Sub TesterA()
    >>>> With Columns(1)
    >>>> .SpecialCells(xlCellTypeConstants, xlTextValues). _
    >>>> EntireRow.Delete
    >>>> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>>> End With
    >>>> End Sub
    >>>> '<<=============
    >>>>
    >>>> As you are new to macros, you may wish to visit David McRitchie's
    >>>> 'Getting
    >>>> Started With Macros And User Defined Functions' at:
    >>>>
    >>>> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>>>
    >>>> You may also wish to look at David's tutorial page:
    >>>>
    >>>> http://www.mvps.org/dmcritchie/excel....htm#tutorials
    >>>>
    >>>> To run the suggested code, try:
    >>>>
    >>>> Copy the code
    >>>> Alt-F11 to open the VBA editor
    >>>> Menus | Insert | Module
    >>>> Paste the code
    >>>> Alt-F11 to return to Excel
    >>>> Select the worksheet of interest
    >>>> Alt-F8 to open the Macro Dialog
    >>>> Select the macro in the dropdown window
    >>>> Run
    >>>>
    >>>> I suggest that you try the code on a copy of your data to verify that
    >>>> the
    >>>> code achieves your intended results.
    >>>>
    >>>>
    >>>> ---
    >>>> Regards,
    >>>> Norman
    >>>>
    >>>>
    >>>> "js" <js@[email protected]> wrote in message
    >>>> news:%[email protected]...
    >>>> > Hi Norman,
    >>>> >
    >>>> > the condition is not numeric,
    >>>> >
    >>>> >>>.SpecialCells(xlCellTypeConstants, xlNumbers).EntireRow.Delete?
    >>>> >
    >>>> > How to add it?
    >>>> >
    >>>> >
    >>>> >
    >>>> > "Norman Jones" <[email protected]> wrote in message
    >>>> > news:[email protected]...
    >>>> >> Hi JS,
    >>>> >>
    >>>> >>> just check id is numeric or empty, then delete?
    >>>> >>
    >>>> >> Try:
    >>>> >>
    >>>> >> '=============>>
    >>>> >> Public Sub Tester()
    >>>> >> With Columns(1)
    >>>> >> .SpecialCells(xlCellTypeConstants, xlNumbers). _
    >>>> >> EntireRow.Delete
    >>>> >> .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    >>>> >> End With
    >>>> >> End Sub
    >>>> >> '<<=============
    >>>> >>
    >>>> >>
    >>>> >> ---
    >>>> >> Regards,
    >>>> >> Norman
    >>>> >>
    >>>> >>
    >>>> >> "js" <js@[email protected]> wrote in message
    >>>> >> news:[email protected]...
    >>>> >>> Hi,
    >>>> >>>
    >>>> >>> I have a excel file like this:
    >>>> >>> id name
    >>>> >>> 1 ll1
    >>>> >>> 2 ll2
    >>>> >>> abc xxxxxxxxxxxxxx
    >>>> >>> 10 ll3
    >>>> >>>
    >>>> >>> 23 ll4
    >>>> >>>
    >>>> >>> my job is to remove the empty line or the id column is not numeric,
    >>>> I
    >>>> >>> manual did it now. I have lot's row. is it possible to do using
    >>>> VBA?
    >>>> >>> just check id is numeric or empty, then delete? I'm new to excel,
    >>>> please
    >>>> >>> help. Thanks.
    >>>> >>>
    >>>> >>>
    >>>> >>
    >>>> >>
    >>>> >
    >>>> >
    >>>
    >>>
    >>> --
    >>> Desert Piranha
    >>>
    >>>
    >>> ------------------------------------------------------------------------
    >>> Desert Piranha's Profile:
    >>> http://www.excelforum.com/member.php...o&userid=28934
    >>> View this thread:
    >>> http://www.excelforum.com/showthread...hreadid=493213
    >>>

    >>
    >>

    >
    >




  11. #11
    js
    Guest

    Re: delete rows

    Thanks Norman Jones...

    "Norman Jones" <[email protected]> wrote in message :
    ....



+ 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