Certain Rows at Bottom

1eric

New Member
Joined
May 14, 2015
Messages
3
How can I get rows that if their cells have a certain value, place that row at the bottom of the table. For example, if my table has a column labeled Employee but the value in the cell is unknown, then i want that row to be placed at the bottom of the table.
 
A quick way is to use a helper column.
In a new (helper) column in your list, create a formula: =IF(C2="Unknown","ZZZ",C2)

C2 represents the first cell in the column with the "Unknown" value. Replace C2 in the formula with the appropriate cell reference.
Autofill the formula down the column.
It will cause all "unknown" values to recalc to ZZZ
Now sort on this column in Ascending order. (It should force all unknowns to the bottom).
 
Upvote 0
I should have added I would prefer a VBA code to do this so that I could create a button and attach the macro to it.
 
Upvote 0
Try this macro...

Change the Constant Values at the top of the macro to determine which column (index number) to sort and what term of move to the bottom.

Code:
Sub SortToBottom()
Dim lR As Long
'===========================================================
'(Specify the column index number to sort EG: Column E = 5)
    Const SortColumn = 4
'(Specify the value to move to the bottom EG: "Unknown")
    Const ValToMove = "Unknown"
'===========================================================


    Application.ScreenUpdating = False
    lR = Range("A" & Rows.Count).End(xlUp).Row
    Columns("A:A").Insert
    Range("A1:A" & lR).FormulaR1C1 = _
        "=IF(RC[" & SortColumn & "]=""" & ValToMove & """,""ZZZ"",RC[" & SortColumn & "])"
    Range("A1:A" & lR).Value = Range("A1:A" & lR).Value
    Range("A1").CurrentRegion.Sort Range("A1"), xlAscending, Header:=xlYes
    Columns("A:A").Delete Shift:=xlToLeft
    Range("A1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top