+ Reply to Thread
Results 1 to 4 of 4

Extract essence of a table

Hybrid View

  1. #1
    Registered User
    Join Date
    07-04-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    2

    Extract essence of a table

    Hi. Have haev a problem im hoping you can help me solve. Its probably not that hard as it could be solved by a while-loop in MatLab, but im not sure how to do it in excel.
    Here it is:
    I have two columns with data, in one all of the rows has values, and in the second most rows are zero and some have values.
    How can i delete the rows that contain zero?

    for instance i want this:
    1 0
    2 1
    3 0
    4 0
    5 1,2
    6 0
    7 0
    8 1,1
    9 0
    to become this:
    2 1
    5 1,2
    8 1,1

    Any thoughts?
    thank you.

  2. #2
    Forum Contributor
    Join Date
    11-26-2011
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    159

    Re: Extract essence of a table

    try dis,
    [code]
    Sub delrows()

    Dim rcntB As Long
    rcntB = Worksheets("sheet1").Range("B" & Rows.Count).End(xlUp).Row
    For i = rcntB To 1 Step -1
    If Cells(i, 2).Value = 0 Then
    Cells(i, 2).EntireRow.Delete
    End If

    Next i
    End Sub
    [\code]

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,610

    Re: Extract essence of a table

    Use XL's filter on 0 values and delete the rows - Same thing with a Macro: a loop is inefficient use the filter

  4. #4
    Registered User
    Join Date
    07-04-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Extract essence of a table

    filter worked. set a filter, then copied the new order. 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