Copy-paste VBA

Excelnoobisme

Board Regular
Joined
Nov 19, 2010
Messages
128
Hi,

i have 2 tabs, 'working' and 'data'.

'working' tab is where i will do my daily work, after done, i will paste to 'data'.
Can i have a marco say, 1st day working i have 200 rows, it will paste to 'data' and on the 2nd day if i have 150 rows, it will go to 'data' and paste starting from row 201...and so on.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Try:
Code:
Sub CopyandMove()
Dim i As Long
With Sheets(1)
   i = .Range("A" & Rows.Count).End(xlUp).Row
   .Range("A1:J" & i).Copy
'change J to whatever letter your last column is in
End With
With Sheets(2)
    If IsEmpty(.Range("A1")) Then
        .Range("A1").PasteSpecial Paste:=xlValues
    Else
        .Range("A1").End(xlDown).Offset(1, 0).PasteSpecial Paste:=xlValues
    End If
End With
End Sub
 
Upvote 0
A1 must be empty.
Where does your data start on page 2?
Do you have a title line on row1 or does your data indeed start in A1?

Michael
 
Upvote 0
I didn't change it from my test code to your requirements. I'm assuming you want row 1 copied over. If this is a header row, then change the red 1 below to 2 (or whatever row your data starts on in working)

Try:
Rich (BB code):
Sub CopyandMove()
Dim i As Long
With Sheets("working")
   i = .Range("A" & Rows.Count).End(xlUp).Row
   .Range("A1:J" & i).Copy
'change J to whatever letter your last column is in
End With
With Sheets("data")
    If IsEmpty(.Range("A1")) Then
       .Range("A1").PasteSpecial Paste:=xlValues
    Else
        .Range("A" & Rows.Count).End(xlUp).Offset(1,0).PasteSpecial Paste:=xlValues
    End If
End With
End Sub
 
Upvote 0
Hi, if i want to safeguard the same data from the same day from pasting twice on a same day how can i do that? My column A is date.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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