Copy and paste range

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I'm a bit suck on this one,

In need some help please to work this one out.

I need to copy ALL DATA on sheet2 Range A-M and paste it in next blank row on sheet1 column B so all the copied data will sit in columns B to N

And I need Todays date going into column A for each row that has been copied over,

Code:
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")

copySheet.Range("A1:M1").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Application.ScreenUpdating = True

Thanks for having a look :eek:
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Change this line
Code:
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

as
Code:
pasteSheet.Cells(Rows.Count, [COLOR=#ff0000][B]2[/B][/COLOR]).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
 
Upvote 0
Hi

Thanks fot that code update, it now pastes the coppied data in to column B, which is good.

My range is wrong as it only copies A1:M1 not all the data in that sheet in this range so if there was 10 rows, then all ten will be copied in range A1:M1. If 1000 rows the 1000 will be copied.

Also I can't get it to put todays date into column A

Code:
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")

copySheet.Range("A1:M1").Copy
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False

Dim Cell As Range
For Each Cell In Target
    If Cell.Column = Range("B:B").Column Then
        If Cell.Value <> "" Then
            Cells(Cell.row, "A").Value = Int(Now)
        Else
            Cells(Cell.row, "A").Value = ""
        End If
    End If
Next Cell

Application.ScreenUpdating = True
 
Last edited:
Upvote 0
Ok I have fixed my code now so that when if pastes in the date in to column B it also adds todays date in Column A

I am still stuck on copying all the data from sheet2 - My range only does 1 row

Code:
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")

[COLOR=#ff0000]copySheet.Range("A1:M1").Copy[/COLOR]
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False

Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    With Range("A2:A" & LastRow)
        .Value = Date
        .NumberFormat = "dd/mm/yy"
    End With

Application.ScreenUpdating = True
End Sub
 
Upvote 0
This is good, the problem now is

1) It copies the heading from sheet2 over to sheet1
2) I loose all format from sheet2, some rows have colors etc.

Code:
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Sheet2")
Set pasteSheet = Worksheets("Sheet1")

copySheet.Range("A1").CurrentRegion.Copy
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
Application.CutCopyMode = False

Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
    With Range("A2:A" & LastRow)
        .Value = Date
        .NumberFormat = "dd/mm/yy"
    End With

Application.ScreenUpdating = True
 
Upvote 0
Still stuck on this one, If anyone could please help on the last few steps, I would save my life
 
Upvote 0
Change this line
Code:
copySheet.Range("A1").CurrentRegion.Copy
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues

as
Code:
copySheet.Range("A1").CurrentRegion.Offset(1, 0).Copy
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Paste
 
Last edited:
Upvote 0
I'm getting a run time error message 438

"Object doesn't support this property or method"

on this like
Code:
pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).Paste
 
Upvote 0
For copy and paste use

copySheet.Range("A1").CurrentRegion.Offset(1, 0).Copy pasteSheet.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0)
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,782
Members
449,259
Latest member
rehanahmadawan

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