ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Move data to top of column (https://www.excelbanter.com/excel-programming/431869-move-data-top-column.html)

Jbm

Move data to top of column
 
Hi,
I'm working in Excel 2007 and I have data in columns A-E, contiguous, and
far less data in G-K non contiguous. All I need to do is move the data in
G-K to the top of the sheet (accounting for a header), still in the same
columns, while leaving A-E untouched. Order is unimportant, could be
alphabetical or anything. The piece of code I tried to use was

Cells.sort Key1:=Range("G:K")

Which moved the data to the top, but didn't account for a header and oddly
copied itself into A-E in the same top rows while moving those original A-E
rows down.

jasontferrell

Move data to top of column
 
Use this:
Range("G:K").Sort Key1:=Range("G2"), Header:=xlYes


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com