You are here:

Excel/Using formulas to sort rows of data automatically

Advertisement


Question
QUESTION: Dear Victor,

I'm making a financial spreadsheet.  I need to be able to sort 5 columns and up to 20 rows (can be less) of data automatically and alphabetically, putting the empty rows last, using formulas.  The columns and rows would be as follows:

Creditor   Interest   Total     Months   Date
we         $2722.84   $7722.84  64       March-15

and up to 19 more rows of data.

I need it automatic so that when stuff changes, these rows sort automatically and without using macros.

I hope you can help, I can't figure it out and must get an answer from somewhere.

Thank You,

Greg

ANSWER: Hi Greg,

In order to sort it automatically, you will need to use VBA macro to capture worksheet events. However, it may not be efficient if the worksheet contains large amount of data.

Let me know if you need a VBA solution and I'll assist.
Thanks.

Regards,
Victor LAN

---------- FOLLOW-UP ----------

QUESTION: Victor,

Thank you for your quick response.  Due to the nature of what I'm trying to do, I can't use VBA macros.  I actually originally used a macro to do this but have found I can't leave it like that,  I intend to use a program to turn my spreadsheet into a program itself, but the program I am using is unable work with macros, I really need to be able to sort these rows using formulas.  I found some data on how to do it using the OFFSET and COUNTA functions together, but I didn't really understand what it was doing.  The link to where this info was is:

http://www.sulprobil.com/html/sorting.html

I think this is how I can do it but this does not explain how to organize the rows alphabetically when you have 5 columns of data to sort.

Does that help?  Could you use this to figure out how to do it for my application?

Thank You,

Greg

Answer
Hi Greg,

I looked at the website and it shows us how to use Excel formulas (without VBA) to generate a sorting key (shown as a rank column on the website) using the data. It works for both alphabetical and numerical data. I tested it using sample data and it works well.

After the sorting key is generated by following the procedure on the website, you will have to sort the data using the sorting key. I can think of a few ways that one could do that.

- Sort feature in Excel.
- Using VBA to sort the key in Excel. This could be done by a button, or a Workbook Open event.

I'm not sure what program you are using and its limitation, but if you have a sorting key it should be possible to sort the data easily.

I hope the above helps, if not, please do not hesitate to write back.
Thank you.

Regards,
Victor  
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

All Answers

Answers by Expert:


Ask Experts

Volunteer


Victor Lan

Expertise

I use Excel at work and can assist you in manipulating and filtering data, creating and using formulas, pivot tables, and writing VBA to solve problems and automate processes. I'm willing to research and find a solution for almost anything in Excel for you.

Experience

3 years of professional Excel experience. I currently work for a global investment bank and our team is responsible for certifying the daily profit and loss of the trading desk. Excel is one of the primary tools used at work.

Organizations
Member of Toastmasters International.

Education/Credentials
BSc Banking and Finance (First Class Honours), University of London. Diploma in Electronics, Computer and Communication Engineering, Singapore Polytechnic.

©2009 About.com, a part of The New York Times Company. All rights reserved.