ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   sort multiple columns of data but not change the data location... Possible? (https://www.excelbanter.com/excel-programming/364405-sort-multiple-columns-data-but-not-change-data-location-possible.html)

[email protected]

sort multiple columns of data but not change the data location... Possible?
 
Hey all,

Hope someone out there can help me with this problem I am having. We
have a phone list done in excel and wish to sort the names
alphabetically but do not wish for the layout to change
It looks like this:

A B C D
Alice 1111 John 1115
Tom 1112 Janet 1116
Kenny 1113

I wish to sort all 4 columns based on the persons name but still have
the 2 column setup.
So sorting would be done based on columns A and C.

Anyone know if this is possible?

Thanks


Jim Jackson

sort multiple columns of data but not change the data location...
 
Activesheet.Range.("A1:B1000").Sort _
Key1:=Worksheets("Sheetname").Columns("A:B"), _
Header:=xlGuess, Order1:=xlAscending

Activesheet.Range.("C1:D1000").Sort _
Key1:=Worksheets("Sheetname").Columns("C:D"), _
Header:=xlGuess, Order1:=xlAscending

Jim


" wrote:

Hey all,

Hope someone out there can help me with this problem I am having. We
have a phone list done in excel and wish to sort the names
alphabetically but do not wish for the layout to change
It looks like this:

A B C D
Alice 1111 John 1115
Tom 1112 Janet 1116
Kenny 1113

I wish to sort all 4 columns based on the persons name but still have
the 2 column setup.
So sorting would be done based on columns A and C.

Anyone know if this is possible?

Thanks



[email protected]

sort multiple columns of data but not change the data location...
 
Thanks Jim,

But where do I put this code? I'm kind of new to excel programming


Jim Jackson wrote:
Activesheet.Range.("A1:B1000").Sort _
Key1:=Worksheets("Sheetname").Columns("A:B"), _
Header:=xlGuess, Order1:=xlAscending

Activesheet.Range.("C1:D1000").Sort _
Key1:=Worksheets("Sheetname").Columns("C:D"), _
Header:=xlGuess, Order1:=xlAscending

Jim


" wrote:

Hey all,

Hope someone out there can help me with this problem I am having. We
have a phone list done in excel and wish to sort the names
alphabetically but do not wish for the layout to change
It looks like this:

A B C D
Alice 1111 John 1115
Tom 1112 Janet 1116
Kenny 1113

I wish to sort all 4 columns based on the persons name but still have
the 2 column setup.
So sorting would be done based on columns A and C.

Anyone know if this is possible?

Thanks




Jim Jackson

sort multiple columns of data but not change the data location
 
Have you added a Command BUtton already? If not, click on "View, Toolbars,
Control Toolbox." On the toolbox you will see a greyed rectangle about the
sixth object from the left. Click it and then click on the spreadsheet where
you want the button to be. You can always relocate it on the sheet later if
need be.

The button should have small circles at the corners, top, bottom and sides.
Double=click the button and your code window will open. There should be a
line that says "Private Sub CommandButton1_Click()" and another below it that
says "End Sub". Place your code between these two lines and you will be set.

Close (or minimize) the code window to see your spreadsheet. Right-click
the button and choose "Properties." In the properties window you can edit
the Caption to read as you need it as well as choosing color, font etc.

Close the Properties window when finished (You can go back to it as needed
using the same method as this time). If the circles still surround the
button, click the leftmost icon on the control toolbox and the button will be
active.

Click it and see it it does what you want. Let me know if you need more
help or if this didn't help.

Jim

" wrote:

Thanks Jim,

But where do I put this code? I'm kind of new to excel programming


Jim Jackson wrote:
Activesheet.Range.("A1:B1000").Sort _
Key1:=Worksheets("Sheetname").Columns("A:B"), _
Header:=xlGuess, Order1:=xlAscending

Activesheet.Range.("C1:D1000").Sort _
Key1:=Worksheets("Sheetname").Columns("C:D"), _
Header:=xlGuess, Order1:=xlAscending

Jim


" wrote:

Hey all,

Hope someone out there can help me with this problem I am having. We
have a phone list done in excel and wish to sort the names
alphabetically but do not wish for the layout to change
It looks like this:

A B C D
Alice 1111 John 1115
Tom 1112 Janet 1116
Kenny 1113

I wish to sort all 4 columns based on the persons name but still have
the 2 column setup.
So sorting would be done based on columns A and C.

Anyone know if this is possible?

Thanks






All times are GMT +1. The time now is 09:39 PM.

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