?
Solved

Excel sorting without disturbing the main file

Posted on 2007-07-27
13
Medium Priority
?
260 Views
Last Modified: 2010-03-05
Hi,

I have a excel sheet with all data and another sheet which has same contents or some differences.
What i want now is to compare 2 sheets and sort the 2nd file as the first sheet.

egards
Sharath
0
Comment
Question by:bsharath
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 7

Expert Comment

by:Jonybrv
ID: 19580847
If you want to check if the column is missing or new in the second file, you can do that using vlookup function. vlookup can be used to check if the data in second file is available in the first file or vice versa.
If your first file is sorted, you can pull up the data from second and first sheet to a new sheet keeping file 1 sort order.


0
 
LVL 7

Expert Comment

by:Jonybrv
ID: 19580850

Oh missed to mention, if you are trying to avoid manual work. You might need to come up with a macro.
0
 
LVL 11

Author Comment

by:bsharath
ID: 19581189
Any help with a Macro
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 29

Expert Comment

by:Badotz
ID: 19581291
Go to Tools->Macro->Create Macro and accept the defaults. Now whatever you do within Excel will be recorded until you stop recording. Handy for figuring out how things work.
0
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 19583676
>What i want now is to compare 2 sheets and sort the 2nd file as the first sheet.

Can you elaborate this point sharath
0
 
LVL 11

Author Comment

by:bsharath
ID: 19583742
Say i have file A as
Sharath
Ramesh
Suresh
Kiram
And second file as
Ramesh
Kiram
So what i want is that the second file will also be changed as the first file sorting
Sharath
Ramesh
Suresh
Kiram
Suresh
0
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 19583744
so the order of the names in the second file should be same as the order of sorting in the first file right.
If thats correct then in the above example you gave, the second file will have only two names Ramesh and Kiran.
0
 
LVL 11

Author Comment

by:bsharath
ID: 19583766
Sorry actuall the the second file will have
Kiran
Ramesh
Sharath
Suresh
0
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 19583809
i still really dont get the objective.sorry buddy
0
 
LVL 11

Author Comment

by:bsharath
ID: 19583848
I have a file A
Which has
Sharath
Reddy
Ramesh in this order
and file B in this order
Ramesh
Sharath
Reddy
Now i want a way for the macro to sort the second file as it is in the first file.

0
 
LVL 13

Expert Comment

by:hiteshgoldeneye
ID: 19584181
try this macro
Sub asort()
s2row=1
For i=1 to Sheet1.UsedRange.Columns.Count
   For j=1 to Sheet1.UsedRange.Columns.Count
      For k=1 to Sheet2.UsedRange.Rows.Count
         if Sheet2.Cells(k,i) = Sheet1.Cells(j,i) then
               temp=Sheet2.Cells(s2row,i)
               Sheet2.Cells(s2row,i) = Sheet2.Cells(k,i)
               Sheet2.Cells(k,i) = temp
        End if
     Next
   Next
Next
                 
End Sub


0
 
LVL 11

Author Comment

by:bsharath
ID: 19587841
I think this is case sensitive.
This is not so acurate.Can you please check its sorting 1st 2 lines. But when there are many rows its not sorting
0
 
LVL 13

Accepted Solution

by:
hiteshgoldeneye earned 2000 total points
ID: 19588399
try this macro
Sub asort()
s2row=1
For i=1 to Sheet1.UsedRange.Columns.Count
   For j=1 to Sheet1.UsedRange.Rows.Count
      For k=1 to Sheet2.UsedRange.Rows.Count
         if UCase(Sheet2.Cells(k,i)) = UCase(Sheet1.Cells(j,i)) then
               temp=Sheet2.Cells(s2row,i)
               Sheet2.Cells(s2row,i) = Sheet2.Cells(k,i)
               Sheet2.Cells(k,i) = temp
               s2row=s2row+1
        End if
     Next
   Next
Next
                 
End Sub
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

615 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