ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   how can you let macro determine to where to copy (https://www.excelbanter.com/excel-discussion-misc-queries/189184-how-can-you-let-macro-determine-where-copy.html)

mohavv

how can you let macro determine to where to copy
 
Hi,

I've got several sheets with the same info but in a different layout
in columns.
The column headers are identical. The sheets have a different number
of rows.

Can I get a macro te "read" the header and copy that cell value to
another sheet under the corresponding header.

Row by row cell by cell.

Cheers,

Harold

Example of sheet: NAM.xls to be copied to: TOTAL.xls

name sz Trays Loss Nett Trays Gross Price ... ... ...
a 10 100 4 96 576
b 12 110 5 105 630
c 14 150 8 142 852
....
....
....

Bob Phillips

how can you let macro determine to where to copy
 
Use Application.Match to find where it is in the target sheet

ColNum = Application.Match(Range("A1",
Workbooks("Total.xls").Worksheets(1).Rows(1)
Workbooks("Total.xls").Worksheets(1).Cells(2,ColNu m).Value =
Range("A2").Value

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"mohavv" wrote in message
...
Hi,

I've got several sheets with the same info but in a different layout
in columns.
The column headers are identical. The sheets have a different number
of rows.

Can I get a macro te "read" the header and copy that cell value to
another sheet under the corresponding header.

Row by row cell by cell.

Cheers,

Harold

Example of sheet: NAM.xls to be copied to: TOTAL.xls

name sz Trays Loss Nett Trays Gross Price ... ... ...
a 10 100 4 96 576
b 12 110 5 105 630
c 14 150 8 142 852
...
...
...





All times are GMT +1. The time now is 04:26 AM.

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