How to copy all data from 1 sheet to another?

danbates

Active Member
Joined
Oct 8, 2017
Messages
377
Office Version
  1. 2016
Platform
  1. Windows
Hi,

Please can someone help me?

What I would like is to be able to copy all the data from the current week sheet and then copy it to my data sheet via VBA code.

I have 53 sheets on my workbook. 1 sheet for each week of the year and then my data sheet.

The data will not be the same amount each week. Some weeks it could be 100 rows and 10 columns and another week it could be 80 rows and 15 columns.

I have formulas in the week sheets so when it comes to pasting it I would like just the values to be pasted please.

Any help would be much appreciated.

Thanks

Dan
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I have some doubts:

Do you want to copy the 52 sheets on a destination sheet?
How will the copy be? sheet1 up, down sheet1 sheet2 and so on?
Which columns do you want to copy?
In which row should the copy start?
 
Upvote 0
Hi,

I just want to copy 1 sheet per week and the sheet number depends on which week number it is. eg this week is week 39 so it would be sheet39.

The copy needs to start from A1 and then copy all the data on the sheet and then paste it to the data sheet. The amount of rows and columns will vary each week.

I have managed to put the following code together so far but I can't figure out how to find the last column of data. In my code I have just set it to column M.

Code:
Option Explicit

Sub COPY_ROW_COLUMN()


Dim LastRow As Long
Dim LastCol As Integer


Sheets("DATA").Cells.ClearContents


With ActiveSheet
    
        LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Select


[COLOR=#ff0000]        LastRow = .Cells(.Rows.Count, "M").End(xlUp).Select[/COLOR]


        Range(Cells(1, 1), ActiveCell).Select


        Selection.Copy


        Range("A1").Select


End With


    Sheets("DATA").Select


    Range("A1").Select


    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False


    Range("A1").Select


End Sub

If you could help me with that then I'd appreciate it.

Thanks

Dan
 
Upvote 0
You didn't answer some of my questions, so I'm going to try to guess, if you have 39 sheets, then you want to copy sheet1, sheet2 to sheet39 on the "data" sheet.
Try this:

Code:
Sub copy_all_data()
  Dim sh As Worksheet, s As Worksheet
  Application.ScreenUpdating = False
  Set sh = Sheets("[COLOR=#0000ff]Data[/COLOR]")
  sh.Cells.ClearContents
  For Each s In Sheets
    If s.Name <> sh.Name Then
      s.Rows("1:" & s.UsedRange.Rows(s.UsedRange.Rows.Count).Row).Copy
      sh.Range("A" & sh.UsedRange.Rows(sh.UsedRange.Rows.Count).Row + 1).PasteSpecial xlPasteValues
    End If
  Next
  Application.ScreenUpdating = True
  MsgBox "Done"
End Sub
 
Upvote 0
Hi,

Thank you for you code.

I apologise for not supplying you with all the info you wanted but your code is very close to what I needed and I'll be able to amend it to suit my needs.

Thank you for you help, it really is appreciated.

Thanks

Dan
 
Upvote 0
Hi,

Thank you for you code.

I apologise for not supplying you with all the info you wanted but your code is very close to what I needed and I'll be able to amend it to suit my needs.

Thank you for you help, it really is appreciated.

Thanks

Dan

Dan, if you can, please post your code so others might be able to use it as an example.
 
Upvote 0

Forum statistics

Threads
1,224,745
Messages
6,180,700
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top