ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to C&P from all Sheets (https://www.excelbanter.com/excel-programming/446846-macro-c-p-all-sheets.html)

Robert Farrand

Macro to C&P from all Sheets
 
I need a Macro to select the same specific cells on every sheet in a workbook and fill in the first master tab to with the info. Basicaly each tab is an employee, and it will have there total wage, so the specific cells will copy the name (B2) and the total wage(G23).

The other issue is there is about 100 tabs, and they are constantly changing, adding and deleting, so the macro needs to adapt to new sheets?

Any ideas?

joeu2004[_2_]

Macro to C&P from all Sheets
 
"Robert Farrand" wrote:
I need a Macro to select the same specific cells on every
sheet in a workbook and fill in the first master tab to
with the info. Basicaly each tab is an employee, and it
will have there total wage, so the specific cells will
copy the name (B2) and the total wage(G23).
The other issue is there is about 100 tabs, and they are
constantly changing, adding and deleting, so the macro
needs to adapt to new sheets?


If the "master tab" is always the first worksheet and all of the remaining
worksheets are to be copied, perhaps the following get you started.

Dim mastRng As Range
Dim i As Long, n As Long
' copy into A2:B2, A3:B3, etc
Set mastRng = Sheets(1).Range("A2")
For i = 2 to Sheets.Count
mastRng.Offset(i-2,0) = Sheets(i).Range("B2")
mastRng.Offset(i-2,1) = Sheets(i).Range("G23")
Next



All times are GMT +1. The time now is 06:52 PM.

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