Help with code that copies data to a second worksheet, but in a different order

Not_Really_Me

New Member
Joined
May 29, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
Hi all,
I'm trying to copy data from the data entry worksheet (Sheet1) to a second, data record worksheet (Sheet2), but I'm not that strong of a programmer so I've mostly been cobbling together different examples. The code below works well, except that I need the content in column I to be pasted at the end but it is always pasted between G and M.


Private Sub CommandButton1_Click()

lastRow = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

For r = 4 To lastRow
If Worksheets("Sheet1").Range("A" & r).Value <> "" Then
Worksheets("Sheet1").Range("A" & r & ":G" & r & ",M" & r & ":S" & r & ",I" & r).Copy

Worksheets("Sheet2").Activate
lastRowRpt = Worksheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("Sheet2").Range("A" & lastRowRpt + 1).Select

ActiveSheet.Paste

End If

Next r

End Sub

There are also several areas where I need to jump back and forth in the order in which column content is pasted over (e.g., A:M, I, O:AO, N, etc.) Is it possible to do this?

Thanks!
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Have you tried using the recorder to record your keystrokes when you do it manually? You can then 'clean up' the recorded code and edit it to make it more useful.
 
Upvote 0
There are many more on line tutorials, but this is a good place to start.

 
Upvote 0

Forum statistics

Threads
1,214,983
Messages
6,122,583
Members
449,089
Latest member
Motoracer88

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