+ Reply to Thread
Results 1 to 6 of 6

Consolidate a Column

Hybrid View

  1. #1
    Registered User
    Join Date
    02-01-2012
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    65

    Consolidate a Column

    I am trying to consolidate a column of say 10 rows down to the cells that do not contain a 0. I have a column that spits out either a name or a zero (depending on its date) and I want to consolidate this column to eliminate all zeros:

    So Column A has the following in it:

    Alpha
    0
    0
    Charlie
    0
    Tango
    Bravo
    Delta
    0
    Foxtrot

    I want column B to eliminate all 0's and Consolidate the column (while keeping the same order) to look like:

    Alpha
    Charlie
    Tango
    Bravo
    Delta
    Foxtrot


    Any ideas would be greatly appreciated thanks

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: Consolidate a Column

    Hi

    You can try this code:

    Sub REMOVEZEROS()
        Dim rcnt As Long, cnt As Long
            
        rcnt = Range("A" & Rows.Count).End(xlUp).Row
        cnt = 1
        
        For i = 1 To rcnt
            If Range("A" & i).Value <> 0 Then
                Range("B" & cnt).Value = Range("A" & i).Value
                cnt = cnt + 1
            End If
        Next
    End Sub
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    Virginia
    MS-Off Ver
    Excel 2010
    Posts
    72

    Re: Consolidate a Column

    There may be an easier/more formula-oriented way, but this will work and won't take long at all:

    Copy all of column A to column B.
    Use find/replace to delete all the 0s.
    Use the info in this link to remove all blank cells: http://www.theexceladdict.com/_t/t031008.htm

  4. #4
    Registered User
    Join Date
    02-01-2012
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Consolidate a Column

    I am looking for a way to do it with a formula and it needs to be self updating

  5. #5
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: Consolidate a Column

    hi par0016. phew i spent almost an hour thinkin of how to do this!
    assuming data is from A2:A11, try:
    =IF(ISERROR(INDEX($A$1:$A$11,SMALL(IF(--($A$2:$A$11<>0),ROW($A$2:$A$11)),ROW(A1)))),"",INDEX($A$1:$A$11,SMALL(IF(--($A$2:$A$11<>0),ROW($A$2:$A$11)),ROW(A1))))
    after copying the formula in the formula bar, press CTRL + SHIFT + ENTER

    let me know if it works

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  6. #6
    Registered User
    Join Date
    02-01-2012
    Location
    New York
    MS-Off Ver
    Excel 2003
    Posts
    65

    Re: Consolidate a Column

    AWESOME! Works great. 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