ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   COMBINE data in several WORKSHEETS with same header row (https://www.excelbanter.com/excel-programming/347840-combine-data-several-worksheets-same-header-row.html)

Coconuts

COMBINE data in several WORKSHEETS with same header row
 
Hi all,
I am struggling with my VBA code at the moment trying to automate the task
of collecting data from several worksheets and placing it in one worksheet to
form one data Worksheet with all of the information. Every source Worksheet
has the same top header row record names but the number of records/rows in
each source Worksheet varies. Ideally the merged data would also sort into
order according to the content of column A or 1 in R1C1 reference.

Thanks for your time.
Geoff
England

bpeltzer

COMBINE data in several WORKSHEETS with same header row
 
The code to select sheets, copy, paste and sort can all be recorded, with the
caveat that you need to determine which rows to copy from each sheet, and
where to paste on the combined sheet. Here's a snippet that will determine
the final non-blank cell in column A of the active worksheet:
Dim LastRow As Long
Range("A65536").Select
Selection.End(xlUp).Select
LastRow = Selection.Row
MsgBox ("Final row of data is " & LastRow)
You can then use the LastRow variable to select the rows to copy (rows("2:"
& lastrow).select) from each separate worksheet and where to paste (range("A"
& lastrow+1).select) to the combined sheet. --Bruce


"Coconuts" wrote:

Hi all,
I am struggling with my VBA code at the moment trying to automate the task
of collecting data from several worksheets and placing it in one worksheet to
form one data Worksheet with all of the information. Every source Worksheet
has the same top header row record names but the number of records/rows in
each source Worksheet varies. Ideally the merged data would also sort into
order according to the content of column A or 1 in R1C1 reference.

Thanks for your time.
Geoff
England


Coconuts

COMBINE data in several WORKSHEETS with same header row
 
Hi Bruce,

thanks for that. I knew the lasts row coding but the rest is a useful step
forward. I will work on it

thanks again
Geoff

"bpeltzer" wrote:

The code to select sheets, copy, paste and sort can all be recorded, with the
caveat that you need to determine which rows to copy from each sheet, and
where to paste on the combined sheet. Here's a snippet that will determine
the final non-blank cell in column A of the active worksheet:
Dim LastRow As Long
Range("A65536").Select
Selection.End(xlUp).Select
LastRow = Selection.Row
MsgBox ("Final row of data is " & LastRow)
You can then use the LastRow variable to select the rows to copy (rows("2:"
& lastrow).select) from each separate worksheet and where to paste (range("A"
& lastrow+1).select) to the combined sheet. --Bruce


"Coconuts" wrote:

Hi all,
I am struggling with my VBA code at the moment trying to automate the task
of collecting data from several worksheets and placing it in one worksheet to
form one data Worksheet with all of the information. Every source Worksheet
has the same top header row record names but the number of records/rows in
each source Worksheet varies. Ideally the merged data would also sort into
order according to the content of column A or 1 in R1C1 reference.

Thanks for your time.
Geoff
England



All times are GMT +1. The time now is 12:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com