+ Reply to Thread
Results 1 to 3 of 3

delete columns and rows-cells equalling zero or any selected value

  1. #1
    Scottie
    Guest

    delete columns and rows-cells equalling zero or any selected value

    Want to select a range of cells horizonally and then delete column when value
    is zero. Same with rows, select cells vertically and then delete rows when
    value is zero.
    THX gang. I'd trade my mother for all your help...

  2. #2
    Bernie Deitrick
    Guest

    Re: delete columns and rows-cells equalling zero or any selected value

    Scottie,

    I hope your mother doesn't visit microsoft.public.excel.worksheet.functions
    ;-)

    Try the sub below.

    HTH,
    Bernie
    MS Excel MVP


    Sub ScottieDeleteZero()
    Dim i As Integer
    If Selection.Rows.Count > 1 And _
    Selection.Columns.Count > 1 Then
    MsgBox "Select either a single row or column of cells"
    Exit Sub
    End If
    If Selection.Rows.Count > 1 Then
    For i = Selection.Cells.Count To 1 Step -1
    If Selection.Cells(i).Value = 0 Then
    Selection.Cells(i).EntireRow.Delete
    End If
    Next i
    Else
    For i = Selection.Cells.Count To 1 Step -1
    If Selection.Cells(i).Value = 0 Then
    Selection.Cells(i).EntireColumn.Delete
    End If
    Next i
    End If
    End Sub


    "Scottie" <[email protected]> wrote in message
    news:[email protected]...
    > Want to select a range of cells horizonally and then delete column when

    value
    > is zero. Same with rows, select cells vertically and then delete rows

    when
    > value is zero.
    > THX gang. I'd trade my mother for all your help...




  3. #3
    Scottie
    Guest

    Re: delete columns and rows-cells equalling zero or any selected v

    You're too damn good MVP...

    "Bernie Deitrick" wrote:

    > Scottie,
    >
    > I hope your mother doesn't visit microsoft.public.excel.worksheet.functions
    > ;-)
    >
    > Try the sub below.
    >
    > HTH,
    > Bernie
    > MS Excel MVP
    >
    >
    > Sub ScottieDeleteZero()
    > Dim i As Integer
    > If Selection.Rows.Count > 1 And _
    > Selection.Columns.Count > 1 Then
    > MsgBox "Select either a single row or column of cells"
    > Exit Sub
    > End If
    > If Selection.Rows.Count > 1 Then
    > For i = Selection.Cells.Count To 1 Step -1
    > If Selection.Cells(i).Value = 0 Then
    > Selection.Cells(i).EntireRow.Delete
    > End If
    > Next i
    > Else
    > For i = Selection.Cells.Count To 1 Step -1
    > If Selection.Cells(i).Value = 0 Then
    > Selection.Cells(i).EntireColumn.Delete
    > End If
    > Next i
    > End If
    > End Sub
    >
    >
    > "Scottie" <[email protected]> wrote in message
    > news:[email protected]...
    > > Want to select a range of cells horizonally and then delete column when

    > value
    > > is zero. Same with rows, select cells vertically and then delete rows

    > when
    > > value is zero.
    > > THX gang. I'd trade my mother for all your help...

    >
    >
    >


+ 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