ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   macro to copy columns to sheet (https://www.excelbanter.com/excel-discussion-misc-queries/16397-macro-copy-columns-sheet.html)

Es

macro to copy columns to sheet
 
I have got a workbook wiht 10 sheets that I want to make
a summary of on a new shteet

I need a macro to copy Range B1:C up to where the cells
with data ends in the first sheet to the new sheet then
go back to the next sheet and copy the same range (the
amount of lines can differ)and paste where in the frist
sell with no data underneath the first copy paste data
Hope I make sense. The sheets has got diferendt names
like Floraland, JFK, Franay.

Dave Peterson

Maybe this little macro will get you closer to what you want.

Option Explicit
Sub testme()
Dim mySelectedSheets As Sheets

Dim wks As Worksheet
Dim RngToCopy As Range

Dim newWks As Worksheet
Dim DestCell As Range

Set mySelectedSheets = ActiveWindow.SelectedSheets
ActiveSheet.Select

Set newWks = Worksheets.Add
Set DestCell = newWks.Range("a1")

For Each wks In mySelectedSheets
With wks
Set RngToCopy = .Range("b1", .Cells(.Rows.Count, "c").End(xlUp))

RngToCopy.Copy _
Destination:=DestCell
With newWks
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With
End With
Next wks
End Sub

It copies B1:C(last used cell in C) to a new sheet for each of the grouped
sheets.

So select the first sheet, then ctrl-click on the tabs of the other sheets you
want.

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Es wrote:

I have got a workbook wiht 10 sheets that I want to make
a summary of on a new shteet

I need a macro to copy Range B1:C up to where the cells
with data ends in the first sheet to the new sheet then
go back to the next sheet and copy the same range (the
amount of lines can differ)and paste where in the frist
sell with no data underneath the first copy paste data
Hope I make sense. The sheets has got diferendt names
like Floraland, JFK, Franay.


--

Dave Peterson


All times are GMT +1. The time now is 04:31 PM.

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