+ Reply to Thread
Results 1 to 4 of 4

Not IsNumeric not working - or is it me?

  1. #1
    Ed
    Guest

    Not IsNumeric not working - or is it me?

    I'm trying to evaluate all cells down a column and delete all rows with a
    non-number in the cell. It was working fine - until I hit "*85"!! The *
    threw everthing off. So I was trying to use Not IsNumeric to evaluate the
    second character of the cell value. But my code is not working. Apparently
    I'm using it wrong. If anyone can help. I'd appreciate it.

    Ed

    Do
    If .Cells(i, 1).Value = "" Or _
    .Cells(i, 1).Value = " " Then
    .Cells(i, 1).EntireRow.Delete
    j = .Rows.Count
    ****** Problem area ******
    ElseIf Len(.Cells(i, 1).Value) > 1 And _
    Not IsNumeric(Left(.Cells(i, 1).Value, 2)) Then
    ****** Problem area ******
    .Cells(i, 1).EntireRow.Delete
    j = .Rows.Count
    Else
    i = i + 1
    End If
    Loop Until i > j



  2. #2
    William
    Guest

    Re: Not IsNumeric not working - or is it me?

    Hi Ed

    A different approach to yours but it may help

    Sub test()
    Application.ScreenUpdating = False
    Dim r As Range
    With ActiveSheet
    ..AutoFilterMode = False
    ..Columns("B:B").Insert Shift:=xlToRight
    Set r = .Range(.Range("A2"), .Range("A" & Rows.Count).End(xlUp))
    r.Offset(0, 1).FormulaR1C1 = "=ISNUMBER(RC[-1])"
    r.Offset(0, 1).Formula = r.Offset(0, 1).Value2
    If Application.CountIf(.Range("B:B"), "False") > 0 Then
    ..Columns("B:B").AutoFilter Field:=1, Criteria1:="FALSE"
    Set r = r.Offset(0, 1).SpecialCells(xlCellTypeVisible)
    ..AutoFilterMode = False
    r.EntireRow.Delete
    End If
    ..Columns("B:B").EntireColumn.Delete
    End With
    Application.ScreenUpdating = True
    End Sub

    --
    XL2002
    Regards

    William

    [email protected]

    "Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message
    news:%[email protected]...
    | I'm trying to evaluate all cells down a column and delete all rows with a
    | non-number in the cell. It was working fine - until I hit "*85"!! The *
    | threw everthing off. So I was trying to use Not IsNumeric to evaluate the
    | second character of the cell value. But my code is not working.
    Apparently
    | I'm using it wrong. If anyone can help. I'd appreciate it.
    |
    | Ed
    |
    | Do
    | If .Cells(i, 1).Value = "" Or _
    | .Cells(i, 1).Value = " " Then
    | .Cells(i, 1).EntireRow.Delete
    | j = .Rows.Count
    | ****** Problem area ******
    | ElseIf Len(.Cells(i, 1).Value) > 1 And _
    | Not IsNumeric(Left(.Cells(i, 1).Value, 2)) Then
    | ****** Problem area ******
    | .Cells(i, 1).EntireRow.Delete
    | j = .Rows.Count
    | Else
    | i = i + 1
    | End If
    | Loop Until i > j
    |
    |



  3. #3
    Don Guillett
    Guest

    Re: Not IsNumeric not working - or is it me?

    try
    Sub delnonnum()
    For i = Cells(Rows.Count, 1).End(xlUp).row To 1 Step -1
    If Not IsNumeric(Cells(i, 1)) Or Cells(i, 1) = "" Then Rows(i).Delete
    Next
    End Sub

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message
    news:%[email protected]...
    > I'm trying to evaluate all cells down a column and delete all rows with a
    > non-number in the cell. It was working fine - until I hit "*85"!! The *
    > threw everthing off. So I was trying to use Not IsNumeric to evaluate the
    > second character of the cell value. But my code is not working.

    Apparently
    > I'm using it wrong. If anyone can help. I'd appreciate it.
    >
    > Ed
    >
    > Do
    > If .Cells(i, 1).Value = "" Or _
    > .Cells(i, 1).Value = " " Then
    > .Cells(i, 1).EntireRow.Delete
    > j = .Rows.Count
    > ****** Problem area ******
    > ElseIf Len(.Cells(i, 1).Value) > 1 And _
    > Not IsNumeric(Left(.Cells(i, 1).Value, 2)) Then
    > ****** Problem area ******
    > .Cells(i, 1).EntireRow.Delete
    > j = .Rows.Count
    > Else
    > i = i + 1
    > End If
    > Loop Until i > j
    >
    >




  4. #4
    KL
    Guest

    Re: Not IsNumeric not working - or is it me?

    Hi Ed,

    "*" isn't the problem, it is the way you loop through cells and delete rows.
    You need to delete rows in the inverted order. Also, you have a number of
    redundant conditions. Try this code:

    Sub test()
    LastRow = Cells(Rows.Count, 1).End(xlUp).Row
    ScreenUpdating = False
    For i = LastRow To 1 Step -1
    If IsEmpty(Cells(i, 1)) Or Not IsNumeric(Cells(i, 1)) Then
    Rows(i).Delete
    End If
    Next
    End Sub

    Regards,
    KL

    "Ed" <ed_millis@NO_SPAM.yahoo.com> wrote in message
    news:%[email protected]...
    > I'm trying to evaluate all cells down a column and delete all rows with a
    > non-number in the cell. It was working fine - until I hit "*85"!! The *
    > threw everthing off. So I was trying to use Not IsNumeric to evaluate the
    > second character of the cell value. But my code is not working.
    > Apparently
    > I'm using it wrong. If anyone can help. I'd appreciate it.
    >
    > Ed
    >
    > Do
    > If .Cells(i, 1).Value = "" Or _
    > .Cells(i, 1).Value = " " Then
    > .Cells(i, 1).EntireRow.Delete
    > j = .Rows.Count
    > ****** Problem area ******
    > ElseIf Len(.Cells(i, 1).Value) > 1 And _
    > Not IsNumeric(Left(.Cells(i, 1).Value, 2)) Then
    > ****** Problem area ******
    > .Cells(i, 1).EntireRow.Delete
    > j = .Rows.Count
    > Else
    > i = i + 1
    > End If
    > Loop Until i > j
    >
    >




+ 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