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

G

ghelwig

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
 
J

Jim Jackson

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
 
J

Jim Jackson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top