Merging Sheets Using VBA

Copper Contributor

Hi there, I'm looking to implement a macro that means that I will be able to merge 2 sheets into a new sheet, for all rows that match in my time columns. Basically I have 2 sheets, each with a time column in column A. I want to copy all of the rows in both sheets that have the same time and put them all together in sheet 3. I have uploaded an example of my problem, would anybody be able to help with this? Many thanks! P.s I understand this can be done with power query, but I really do need this done with VBA!

5 Replies

@Rory123908 

 

I have a VBA code that does that, i shall help you

Let me download the excel file and do it and send it back to you

wow, sounds great! Thanks very much!

@Rory123908 Done! i created a new sheet called it data, so i can use vba to combine them based on their matching rows, and i told VBA to create a new column at the end to indicate the sheet names, like sheet1 and sheet 2

Hi, many thanks for your help, unfortunately this was not what I was looking for. In this new sheet, I only want rows which time matches in both. For example in sheet 1, there is time 0,1,2,3,4,5,6,7,9,10 (seconds), and in sheet2 there is time 0,2,4,6,8,10. Therefore, I am looking to merge the cells in sheet 3 so that the rows (0,2,4,6,10) are merged. Are you able to do this?
Oh, now i understand what you mean!