You are here:

Excel/Complicated Macro Help with Sorting


QUESTION: Good morning,

I am trying to use a series of formulas and/or macros and/or VBA (?) to essentially create an update-able spreadsheet.  I get raw data from a separate program and copy and paste it into Excel and would like to have Excel then take this data and automatically update a spreadsheet with information about customers and their total quantities purchased of each product and total dollars spent etc.
One big problem I keep running into is that there would need to be a way to add rows (which I don't know how to do with formulas) when a new customer is identified and plug that customer in the rest of the customers in alphabetical order, as well as be able to identify when a current customer has ordered a new product (thus requiring a new row added for that customer in the updating spreadsheet).

For sorting, I have tried a formula such as this:

=IFERROR(INDEX($A$2:$A$20, MATCH(0, COUNTIF($B$1:B2, $A$2:$A$20), 0)),"")

Thank you very much for any help you can provide.



IF I understand correctly what you need then you will need a few macros.  One to add a new row(s) when a new customer(s) is detected and then to sort the newly update list after the new data has been added AND another one to just sort, perhaps, when data changes that would require a sort but without new rows being added.  Formulas can not perform actions, like adding new rows or sorting.  They ONLY return results.

I can write these macros for you but not for free unfortunately.  IF you want me to write them for you I will need more info, such as where (name of file, path, etc.)  does the code need to look for the new data to see if there are any new customers and what columns are the data in that needs to evaluated.

I can write some code that will prompt you for this information to make it more dynamic in case things change later.  Just let me know.  I will need copies of your files if you choose to pursue using me.



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


Thanks for the response.  How much would this service cost?


You're welcome.  Since I don't have ALL the details yet, files layouts specifically, then it is hard for me to say.  It SHOULD be nominal, probably about $50, but that is only an estimate.  Fell free to send me the files and as much as detailed info as possible if you want me to help.

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




I can provide help with most all EXCEL questions and most all questions about writing EXCEL macros. I have been developing macros for about 10 years in EXCEL and have switched to it from Lotus 1-2-3 after about 10 years of writing macros in it. Typically, I will not write a macro for you unless it is very short because of all the details a macro has to know about to work every time and all the time are rarely provided. If I am not given ALL the details, circumstances, and situations then a "good" macro can not be written. Please understand that I do not know it all and will be the first to say so. As politely as possible, I don't write macros for people on this site who need one, want one, seem to imply that they need one, and/or seem to think I am expected to write one UNLESS they are very short, quick, and simple. 99% of all macros are more involved than what you think and rarely am I provided with enough specific and complete details to have the code work the first time and every time. This typically means too many follow-up emails, and subsequent macro changes due to lack of specific details, just to get those details so that the macro would work, all of which is on my own free time. The voice of experience from responding to many questions from people who ask me to write a macro for them from this site tells me this. I don't mean to come across as unhelpful but macros are usually very specific and without ALL of the specifics the macro I would write will not address all of your needs and the layout, location, formatting, conditions, etc. of your data and any related files the macro would have to work with. What seems like a simple task to you is almost always more involved than what you think to have the macro ALWAYS work in EVERY situation. If you have a macro you have already written and have a question about it then perhaps I could help with that. I am sure and hope you can and do understand.

©2017 All rights reserved.