ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Workbook Copy Query (https://www.excelbanter.com/excel-programming/414895-macro-workbook-copy-query.html)

carla 7[_2_]

Macro Workbook Copy Query
 
Help deperately needed...I am trying to create a macro that will do the
following:
Copy the value of cell M4 for each worksheet in a particular workbook and
paste it to a new workbook, BUT the cells should be pasted one cell down
consecutivley in th the destination workbook.

Can anyone help me this?

Thanks

Wigi

Macro Workbook Copy Query
 
Sub simpleloop()

Const sCell As String = "$M$4"

Dim ws As Worksheet
Dim wb As Workbook

Set wb = Application.Workbooks.Add

For Each ws In ThisWorkbook.Worksheets

wb.Sheets(1).Range("B" & Rows.Count).End(xlUp).Offset(1).Value =
ws.Range(sCell).Value

Next

End Sub



--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"carla 7" wrote:

Help deperately needed...I am trying to create a macro that will do the
following:
Copy the value of cell M4 for each worksheet in a particular workbook and
paste it to a new workbook, BUT the cells should be pasted one cell down
consecutivley in th the destination workbook.

Can anyone help me this?

Thanks


carla 7

Macro Workbook Copy Query
 
Macro did not work....I have a workbook with many worksheets. However, each
worksheet has is formatted the same. Cell M4 contains a value (2007 revenue
figures) for a company, each company is respectively placed in a worksheet.
The first company is GM, so cell M4 contains GMs 2007 gross revenue amount.
The second company is Crysler, so cell M4 contains Crysler's 2007 gross
revenue amount. There are over 100 companies.

What I want is a macro that will copy the value from cell M4 in each
worksheet from that workbook which contains revenue detail, and paste them to
a new workbook, BUT the values should be entered one cell down in a
consecutive manner in that new (destination) workbook.

Sorry I was not clearer earlier. I appreciate the feedback.

"Wigi" wrote:

Sub simpleloop()

Const sCell As String = "$M$4"

Dim ws As Worksheet
Dim wb As Workbook

Set wb = Application.Workbooks.Add

For Each ws In ThisWorkbook.Worksheets

wb.Sheets(1).Range("B" & Rows.Count).End(xlUp).Offset(1).Value =
ws.Range(sCell).Value

Next

End Sub



--
Wigi
http://www.wimgielis.be = Excel/VBA, soccer and music


"carla 7" wrote:

Help deperately needed...I am trying to create a macro that will do the
following:
Copy the value of cell M4 for each worksheet in a particular workbook and
paste it to a new workbook, BUT the cells should be pasted one cell down
consecutivley in th the destination workbook.

Can anyone help me this?

Thanks



All times are GMT +1. The time now is 10:32 AM.

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