Copy Paste two rows to two separate areas on another sheet

Status
Not open for further replies.

DaleKeel

Board Regular
Joined
Sep 11, 2019
Messages
56
Office Version
  1. 2013
Platform
  1. Windows
I have Excel 2013. I need a macro that will do the following.
I have two rows that need to be copied to another sheet, say "XXXYYY" at the bottom of different columns, in the first unoccupied row, depending on the name in cells C7 and C8
Row one occupies A7:J7
Row two occupies A8:J8
If the row has xxx in cell C7 or C8 then it goes to the bottom of the columns starting with column A.
If the row has yyy in cell C7 or C8 then it goes to the bottom of the columns starting with column N.

Thank you very much for your time
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Check if the following is what you need. Run the code on the source sheet.

VBA Code:
Sub Copy_Paste_two_rows()
  With Sheets("XXXYYY")
  If Range("C7") = "xxx" Then
    .Range("A" & Rows.Count).End(xlUp)(2).Resize(1, 10).Value = Range("A7:J7").Value
  ElseIf Range("C7") = "yyy" Then
    .Range("N" & Rows.Count).End(xlUp)(2).Resize(1, 10).Value = Range("A7:J7").Value
  End If
  If Range("C8") = "xxx" Then
    .Range("A" & Rows.Count).End(xlUp)(2).Resize(1, 10).Value = Range("A8:J8").Value
  ElseIf Range("C8") = "yyy" Then
    .Range("N" & Rows.Count).End(xlUp)(2).Resize(1, 10).Value = Range("A8:J8").Value
  End If
  End With
End Sub
 
Upvote 0
PERFECT!
Thank you again.
I have one last thing that would make my life perfect :)

I have a Macro that copies the range of A7:M8 on BitSheet1 to the first empty rows (bottom) on sheet "ORDERS"
Sub COPYTOFIRSTEMPTYROW()
'
' COPYTOFIRSTEMPTYROW Macro
'
'
Range("A7:M8").Select
Selection.Copy
Sheets("ORDERS").Select
Range("A1048576").Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub

Then I go to the sheet named "ENTERHERE" where I have formulas in the last row that pulls the information from different cells of rows in the worksheet "ORDERS"
Right now I manually highlight the last row of ENTERHERE from A:AE and pull down the highlighted area two rows
to copy down (pull in) the rows that I just pasted in the ORDERS sheet.

and the information that I pasted on ORDERS magically appears.

I sometimes repeat this many times in a day with new information I paste in ORDERS

It would be A LOT of time savings if I had one macro to do both.
Please help if you have the time.
 
Upvote 0
I did not know if this is right but when you did not reply for a long time I posted this question to the general public. Sorry for not waiting
 
Upvote 0
I did not know if this is right but when you did not reply for a long time I posted this question to the general public. Sorry for not waiting
Do not worry, today is Sunday and I am with the family, so I could not answer.
And yes, the correct thing is to publish a new thread for each different requirement.

I am glad to continue helping you. Thanks for the feedback.
 
Upvote 0
FROM ABOVE:

"Then I go to the sheet named "ENTERHERE" that pulls(references) the information from different cells of rows in the worksheet "ORDERS"
Right now I manually highlight the last row of ENTERHERE from A:AE and pull down the highlighted area two rows
to copy down (pull in) the rows that I just pasted in the ORDERS sheet."

I made this Sub Macro4() (as an example) but it is just a copy paste in the same "ENTERHERE" sheet and it does not find the new bottom row.

Sub Macro4()
'
' Macro4 Macro
'
'
Range("A356:S356").Select
Selection.AutoFill Destination:=Range("A356:S358"), Type:=xlFillDefault
Range("A356:S358").Select
End Sub

What I would like to do is
Execute the macro on the "Orders" sheet.
On the "ENTERHERE" sheet I want the macro to find the current last row with data and copy that row down two rows every time I execute the macro
This will bring in the new data that I put in the last two rows on the ORDERS sheet. I put new data in the last two rows of the order sheet many times a day.

Thanks for looking at my problem
 
Upvote 0
This is now a duplicate Copy Down Formulas

Please do not post the same question multiple times.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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