Auto move excel columns

... /
September 14, 2009 at 09:06:37
Specs: XP Home/Pro, 1gig
I have a small spreadsheet.
7 Colunms 9 Rows.
In the columns are numbers I would like Colunm H's number to move it's entire row to top of the sheet automatically when it becomes the largest number.

And if possible, if Colunm H has two rows with the same # Colunm C's # would be the next default as to which rows at the top (if this is to complicated it's not a big problem)

See More: Auto move excel columns

Report •

September 15, 2009 at 13:20:28

You can sort your rows of data with a simple macro.

I have just done this with a single sort on Column H, but when you look at it, and the associated documentation you will see that you can sort by additional columns.

The macro will not run automatically as it is now, but you can make it run automatically using cell change events later.

Anyway, I thought that you might like to try this out as a starter.

Link the Macro to a button to run it whenever needed.

The sorting is only on the range of cells used, not whole rows.

1. Put a header row above your data. Any series of names will do.
2. Select the header cells and all the data cells and name the range.
3. In Excel 2003 this is Insert - Name - Define.
4. Remember that range names cannot contain spaces
5. Name the range "SortRows" as it matches what I used in the Macro
6. In VBA (Alt+f11) enter the following:

Sub TopRow()
Dim rngSortRows As Range

Set rngSortRows = ActiveSheet.Range("SortRows")
rngSortRows.Sort Key1:=Range(rngSortRows.Rows(0).End(xlToRight).Address), _

End Sub

(rngSortRows.Sort to =xlDescending is all one row)

Link the macro to a button.
If you put this code in a standard module in Personal.xls, it will be easy to make the link to the button
1. Right click on toolbar and Select Customize
2. Commands Tab and select Macro on left side
3. Drag Custom button onto a toolbar.
4. Right click Smiley face and Assign Macro
5 In list select Personal.xls!TopRow

Hope this gives you a starting point


Report •
Related Solutions

Ask Question