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
50
Office Version
2013
Platform
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
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,759
Office Version
2007
Platform
Windows
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
 

DaleKeel

Board Regular
Joined
Sep 11, 2019
Messages
50
Office Version
2013
Platform
Windows
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.
 

DaleKeel

Board Regular
Joined
Sep 11, 2019
Messages
50
Office Version
2013
Platform
Windows
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
 

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
11,759
Office Version
2007
Platform
Windows
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.
 

DaleKeel

Board Regular
Joined
Sep 11, 2019
Messages
50
Office Version
2013
Platform
Windows
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
40,849
Office Version
365
Platform
Windows
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).
 
Status
Not open for further replies.

Watch MrExcel Video

Forum statistics

Threads
1,099,376
Messages
5,468,248
Members
406,575
Latest member
Joe00

This Week's Hot Topics

Top