Solved

Sorting alphabetically across different sheets

Posted on 2011-02-25
9
229 Views
Last Modified: 2012-05-11
I have 2 sheets. In Sheet1 names are entered in column A for use of the corresponding cell in Sheet2. In Sheet2 additional information is entered in column B. When adding or removing names from Sheet1 I would want to sort alphabetically. That's easy when sorting in Sheet2, but I would want to sort in Sheet1, but keeping column B in Sheet2 in the same row as the name it was entered with in column A.
Attached is a simple example before and after. Before is information entered, after is what I want it to look like by only sorting in Sheet1.

How do I do that
Before.xls
after.xls
0
Comment
Question by:Brasch
9 Comments
 
LVL 4

Expert Comment

by:MarioAlcaide
ID: 34977994
Hello,

Maybe the following link will hjelp you, it's a similar case:

http://excel.bigresource.com/Track/excel-HucbZZMM/
0
 
LVL 5

Expert Comment

by:Kannan253984
ID: 34978712

Hi,

You will have to write a macro to read the content from Sheet1 and write into sheet2 and do the sorting thru macro. as of now you are referring the sheet 1 cells in sheet 2 cell. sheet 2 will not know that, the sheet 1 has done sorting.

KK,
0
 

Author Comment

by:Brasch
ID: 34984761
@MarioAlcaide;
The formula in the link might work, but I simply do not completely understand what it does, so very hard to fit my needs

@Kannan;
problem is, that I have 35 sheets that I need to sort - I'd rather not have to sort all of them one after another. Anyway, what actions would that macro contain?

0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 34985317
Brasch: The problem is the formulas in column A of Sheet 2.

If there were not formulas then you could have used the code below to sort the entire range of sheets.

Sub SortAll()
    Dim LastRow As Long, lastCol As Long
    Dim ws As Worksheet
    
    For Each ws In ThisWorkbook.Sheets
        LastRow = ws.UsedRange.Rows.Count
        lastCol = ws.UsedRange.Columns.Count
        
        colname = Split(ws.Cells(, lastCol).Address, "$")(1)

        ws.Range("A2:" & colname & LastRow).Sort Key1:=ws.Range("A2"), _
        Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortTextAsNumbers
    Next
End Sub

Open in new window


Sid
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Brasch
ID: 34985332
Well, the problem in example isn't (or shouldn't be) Sheet1 - it's basically a list of names - that could just as well be entered into sheet2, sheet1 is just for user-friendlyness, since the rest of the sheets also contain relevant data aside from the names. The problem arises in the "real world" when applying to the rest of my sheets. I somehow need to attach an entire row to the first cell in the row
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34985347
If you have formulas referring to some other cell then sorting them will give you some undesired results. If only the 1st column in 2nd or the 3rd or any other sheet is connected to the 1st column of another sheet then it will create a problem.

Try and run the code that I gave and see what happens.

Sid
0
 

Author Comment

by:Brasch
ID: 34985363
It's getting quite late here, I'll give it a go after some sleep
0
 

Author Comment

by:Brasch
ID: 34987977
well, the code basically works the same way as the sort a-z, not much help. Considered putting all the sheets together in one "Enter Data" sheet, but since I'm using Office 2003 I'm running out of columns
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34991629
Brasch: Can I see the actual Excel File?

Sid
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now