• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy rows from one table to another based on names

skmerrey

New Member
Hi,
I was hoping someone could help with some VBA code for my spreadsheet. My wife works with schools, teaching kids gym throughout the week at different times. I want to make the spreadsheet for her schedule more automated.

I have 2 tables on the same sheet, one below the other. They both have the same columns and a list of the same 18 schools with a list of the dates for the classes and then times of the day for each class. The top table is sorted by the school name, this table must remain static in the same order as it links to several other sheets in the workbook.

The bottom table is sorted by the day of the week and the order of schools can change depending when the classes will be (this can constantly change, the the bottom table is the one that is edited). I currently have a macro button on the top table for each school that can copy the row for the bottom table based on the position of the active cell (I have to do this for each school, its not much quicker than copy/paste manually.

I want to write a code that will search for the school name in the bottom table and then copy/paste that row into the top table against the correct school in one action, then I will link this to a single macro button.

Any help on where to start with this would be greatly appreciated. Below is an example table.table example.JPG

Thanks
Skmerrey
 
Hi skmerrey, and welcome to the forum! :awesome:

Would it be possible to upload your workbook, or at least just the sheet with the two tables? At first image, it appears that you may be inadvertently overc-omplicating the problem. Or, we can use the AdvFilter to quickly transfer the data. With the images you posted, it looks like the exact same data, just sorted differently. If that's the case, we'll just write our macro to do a copy & sort.
 
Hi Luke,
Thanks for your response. your probably right , I may be over complicating things a little lol. I have uploaded the sheet, as the workbook contains confidential info. I have explained on the sheet exactly what I need, and also I have explained the current macros I have written. you will notice I've made a few changes to the bottom table from the previous image, this is the full schedule. However I have explain what information needs to be copied to the top table.

Again thanks for any help you can give.

Thanks
shaun
 

Attachments

  • test sheet 2.xlsm
    17.3 KB · Views: 2
Hi Shaun,

I'm still not positive why you need two tables, as the links should be safe even if you sort, but your actual file may vary. My recommendation based on your sample would be to use a formula, like in the attached, to transfer the info. Will this work?
 

Attachments

  • School Links.xlsx
    11.9 KB · Views: 3
Back
Top