+ Reply to Thread
Results 1 to 6 of 6

Delete rows with numeric values, leave rows with text

  1. #1
    GSpline
    Guest

    Delete rows with numeric values, leave rows with text

    I am trying to delete any row in a worksheet that has a numeric value in a
    specific column (assume column A) while leaving any row intact that contains
    a text value in that same column. I was able to get numeric values to
    delete, but the text rows would also delete... leaving no data at all because
    all of it was deleted along with the numeric. I saw another post (number
    less than 100) and was able to use that code to some extent, but I am not
    sure how to modify it to affect only numeric & skip text. Here is the code
    from that post, submitted by David:

    Sub Macro1()
    Range("I1").Select
    Do Until ActiveCell.Value = ""
    If ActiveCell.Value < 100 Then
    z = ActiveCell.Row
    Rows(z).Delete
    ActiveCell.Offset(-1, 0).Select
    Else
    End If
    ActiveCell.Offset(1, 0).Select
    Loop
    End Sub

    and here is how I modified it:

    Sub Macro1()
    Range("A2").Select
    Do Until ActiveCell.Value = ""
    If ActiveCell.Value >= 0 Then
    z = ActiveCell.Row
    Rows(z).Delete
    ActiveCell.Offset(-1, 0).Select
    Else
    End If
    ActiveCell.Offset(1, 0).Select
    Loop
    End Sub


    I purposely want to start the macro in cell A2 and continue to the end of
    the data at the bottom of that column (it will vary). I am about to go nutty
    with this one, any help would be appreciated.

    Thanks.

  2. #2
    PY & Associates
    Guest

    Re: Delete rows with numeric values, leave rows with text

    change if activecell.value<100 then
    to if isnumeric(activecell) then

    "GSpline" <[email protected]> wrote in message
    news:[email protected]...
    > I am trying to delete any row in a worksheet that has a numeric value in a
    > specific column (assume column A) while leaving any row intact that

    contains
    > a text value in that same column. I was able to get numeric values to
    > delete, but the text rows would also delete... leaving no data at all

    because
    > all of it was deleted along with the numeric. I saw another post (number
    > less than 100) and was able to use that code to some extent, but I am not
    > sure how to modify it to affect only numeric & skip text. Here is the

    code
    > from that post, submitted by David:
    >
    > Sub Macro1()
    > Range("I1").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value < 100 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    > and here is how I modified it:
    >
    > Sub Macro1()
    > Range("A2").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value >= 0 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    >
    > I purposely want to start the macro in cell A2 and continue to the end of
    > the data at the bottom of that column (it will vary). I am about to go

    nutty
    > with this one, any help would be appreciated.
    >
    > Thanks.




  3. #3
    Norman Jones
    Guest

    Re: Delete rows with numeric values, leave rows with text

    Hi G,

    Try:
    '=================>>
    Public Sub Tester01()
    Dim rng As Range
    Dim WB As Workbook
    Dim SH As Worksheet

    Set WB = ActiveWorkbook '<<========== CHANGE
    Set SH = WB.Sheets("Sheet1") '<<========== CHANGE
    Set rng = SH.Columns(1).SpecialCells(xlConstants, xlNumbers)

    rng.EntireRow.Delete

    End Sub
    '<<=================

    ---
    Regards,
    Norman



    "GSpline" <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to delete any row in a worksheet that has a numeric value in a
    > specific column (assume column A) while leaving any row intact that
    > contains
    > a text value in that same column. I was able to get numeric values to
    > delete, but the text rows would also delete... leaving no data at all
    > because
    > all of it was deleted along with the numeric. I saw another post (number
    > less than 100) and was able to use that code to some extent, but I am not
    > sure how to modify it to affect only numeric & skip text. Here is the
    > code
    > from that post, submitted by David:
    >
    > Sub Macro1()
    > Range("I1").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value < 100 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    > and here is how I modified it:
    >
    > Sub Macro1()
    > Range("A2").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value >= 0 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    >
    > I purposely want to start the macro in cell A2 and continue to the end of
    > the data at the bottom of that column (it will vary). I am about to go
    > nutty
    > with this one, any help would be appreciated.
    >
    > Thanks.




  4. #4
    GSpline
    Guest

    RE: Delete rows with numeric values, leave rows with text



    "GSpline" wrote:

    > I am trying to delete any row in a worksheet that has a numeric value in a
    > specific column (assume column A) while leaving any row intact that contains
    > a text value in that same column. I was able to get numeric values to
    > delete, but the text rows would also delete... leaving no data at all because
    > all of it was deleted along with the numeric. I saw another post (number
    > less than 100) and was able to use that code to some extent, but I am not
    > sure how to modify it to affect only numeric & skip text. Here is the code
    > from that post, submitted by David:
    >
    > Sub Macro1()
    > Range("I1").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value < 100 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    > and here is how I modified it:
    >
    > Sub Macro1()
    > Range("A2").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value >= 0 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    >
    > I purposely want to start the macro in cell A2 and continue to the end of
    > the data at the bottom of that column (it will vary). I am about to go nutty
    > with this one, any help would be appreciated.
    >
    > Thanks.


  5. #5
    GSpline
    Guest

    RE: Delete rows with numeric values, leave rows with text

    Both responses worked, thank you very much.



    "GSpline" wrote:

    > I am trying to delete any row in a worksheet that has a numeric value in a
    > specific column (assume column A) while leaving any row intact that contains
    > a text value in that same column. I was able to get numeric values to
    > delete, but the text rows would also delete... leaving no data at all because
    > all of it was deleted along with the numeric. I saw another post (number
    > less than 100) and was able to use that code to some extent, but I am not
    > sure how to modify it to affect only numeric & skip text. Here is the code
    > from that post, submitted by David:
    >
    > Sub Macro1()
    > Range("I1").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value < 100 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    > and here is how I modified it:
    >
    > Sub Macro1()
    > Range("A2").Select
    > Do Until ActiveCell.Value = ""
    > If ActiveCell.Value >= 0 Then
    > z = ActiveCell.Row
    > Rows(z).Delete
    > ActiveCell.Offset(-1, 0).Select
    > Else
    > End If
    > ActiveCell.Offset(1, 0).Select
    > Loop
    > End Sub
    >
    >
    > I purposely want to start the macro in cell A2 and continue to the end of
    > the data at the bottom of that column (it will vary). I am about to go nutty
    > with this one, any help would be appreciated.
    >
    > Thanks.


  6. #6
    GSpline
    Guest

    Re: Delete rows with numeric values, leave rows with text

    This method seems to work fine after implementation, however, now I get a row
    of "(blank)" entries as the very last row in my pivot table. I cannot figure
    out a way to prevent this from happening. Can anyone explain exactly what
    causes this, and does anyone have a code solution or ideas to prevent this
    from appearing?



    "PY & Associates" wrote:

    > change if activecell.value<100 then
    > to if isnumeric(activecell) then
    >
    > "GSpline" <[email protected]> wrote in message
    > news:[email protected]...
    > > I am trying to delete any row in a worksheet that has a numeric value in a
    > > specific column (assume column A) while leaving any row intact that

    > contains
    > > a text value in that same column. I was able to get numeric values to
    > > delete, but the text rows would also delete... leaving no data at all

    > because
    > > all of it was deleted along with the numeric. I saw another post (number
    > > less than 100) and was able to use that code to some extent, but I am not
    > > sure how to modify it to affect only numeric & skip text. Here is the

    > code
    > > from that post, submitted by David:
    > >
    > > Sub Macro1()
    > > Range("I1").Select
    > > Do Until ActiveCell.Value = ""
    > > If ActiveCell.Value < 100 Then
    > > z = ActiveCell.Row
    > > Rows(z).Delete
    > > ActiveCell.Offset(-1, 0).Select
    > > Else
    > > End If
    > > ActiveCell.Offset(1, 0).Select
    > > Loop
    > > End Sub
    > >
    > > and here is how I modified it:
    > >
    > > Sub Macro1()
    > > Range("A2").Select
    > > Do Until ActiveCell.Value = ""
    > > If ActiveCell.Value >= 0 Then
    > > z = ActiveCell.Row
    > > Rows(z).Delete
    > > ActiveCell.Offset(-1, 0).Select
    > > Else
    > > End If
    > > ActiveCell.Offset(1, 0).Select
    > > Loop
    > > End Sub
    > >
    > >
    > > I purposely want to start the macro in cell A2 and continue to the end of
    > > the data at the bottom of that column (it will vary). I am about to go

    > nutty
    > > with this one, any help would be appreciated.
    > >
    > > Thanks.

    >
    >
    >


+ 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