DATA COPY FROM ONE SHEET TO ANOTHER

shahzeb123

Board Regular
Joined
Jul 29, 2021
Messages
61
Office Version
  1. 2016
Platform
  1. Windows
Below code is working fine and it is doing what i need. However, only one problem remains that it pasting the data in 1 row only not going into next row.

What i need is it should always paste the data into the next available blank column


VBA Code:
Sub Button1_Click()
    Dim R&
        R = Sheet2.Cells(Rows.Count, 1).End(xlUp)(2).Row
        Sheet2.Cells(R, 12).Value = Sheet1.[F24].Value
          Sheet2.Cells(R, 2).Value = Sheet1.[D14].Value
          Sheet2.Cells(R, 3).Value = Sheet1.[D15].Value
          Sheet2.Cells(R, 4).Value = Sheet1.[D16].Value
          Sheet2.Cells(R, 5).Value = Sheet1.[D20].Value
          Sheet2.Cells(R, 5).Value = Sheet1.[D20].Value
          Sheet2.Cells(R, 6).Value = Sheet1.[D21].Value
          Sheet2.Cells(R, 7).Value = Sheet1.[M1].Value
          Sheet2.Cells(R, 8).Value = Sheet1.[D5].Value
          Sheet2.Cells(R, 9).Value = Sheet1.[G15].Valu
          Sheet2.Cells(R, 10).Value = Sheet1.[G16].Value
          Sheet2.Cells(R, 11).Value = Sheet1.[G19].Value
          Sheet2.Cells(R, 13).Value = Sheet1.[G43].Value
          Sheet2.Cells(R, 14).Value = Sheet1.[G44].Valu
          Sheet2.Cells(R, 15).Value = Sheet1.[G45].Value
          Sheet2.Cells(R, 16).Value = Sheet1.[G46].Value
          Sheet2.Cells(R, 17).Value = Sheet1.[D35].Value
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try using
Rich (BB code):
R = Sheet2.Cells(Rows.Count, 2).End(xlUp)(2).Row
 
Upvote 0
Solution
Thank you so much.

Need one more help if you can, is there any way that i can add serial # also in this that +1 should be added in every time i use the button.
 
Upvote 0
As that is a totally different question, it needs a new thread. Thanks
 
Upvote 0
OK Thanks.

One more question can I have the code where it check for duplication before pasting the data ?
 
Upvote 0
Once again, that has nothing to do with your original question & so needs a new thread.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

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