PDA

View Full Version : Copying and sorting rows from multiple tabs to another tab



omar23j
10-02-2018, 11:36 AM
Hi,


I have multiple tabs ( A,B,C,D,E,F AND G) in an excel file that contain multiple rows ( from row 2 until indefinite). Each of these rows contain information in columns A to Y.
I want to paste each of these rows inside a new tab ''New'' in the positions ( row 2 until indefinite). Once that is done I need the rows to be sorted by ascending order based on the index number contained in Column A.

I attempted solving this by doing a copy paste operation from the original tabs to the new one. But that would not take into account how many rows there is in a specific tab. I need to set a condition where I am copying rows until the following row is empty.


If I am not clear enough or not providing enough information please let me know.
Any help is appreciated,
Thanks!

werafa
10-02-2018, 12:54 PM
You have four steps here.

1: ID the row to copy the data into.

try



dim destSheet as worksheet
dim destRow as long
destRow = destSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

2: ID the lastrow in your 'copy from' range - use method above

3: copy the data - you can set the copy from data as a range, or use the 'copy [destination]' command

4: sort the fields. turn on the macro recorder and sort on column 'A'. to re-run this as code, you will need to delete old sort criteria before re-applying them

good luck
Werafa

omar23j
10-03-2018, 06:38 AM
You have four steps here.

1: ID the row to copy the data into.

try



dim destSheet as worksheet
dim destRow as long
destRow = destSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

2: ID the lastrow in your 'copy from' range - use method above

3: copy the data - you can set the copy from data as a range, or use the 'copy [destination]' command

4: sort the fields. turn on the macro recorder and sort on column 'A'. to re-run this as code, you will need to delete old sort criteria before re-applying them

good luck
Werafa

thanks, that should get me something to start with