chivis2504
New Member
- Joined
- Aug 27, 2020
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello everyone,
I'm really new in VBA. I tried to figure out this by myself using other codes I found online, but I have errors.
I have 4 sheets (New York, California, Virginia, and Summary). The first 3 have values in columns A to O.
I need a code to copy the complete row from the 3 sheets (New York, California, Virginia) and paste it in the next available row in sheet "Summary" based on the value in the column "STATUS" (Column N). If value is equal to one of the following "Submit CLNT, Intvw CLNT, Submit CUST, Intvw CUST" then copy to next available row in sheet "Summary".
Also, if possible, in the sheet “Summary” I need rows to be delete it if the value in the column "STATUS" in the 3 first sheets changes to any other than "Submit CLNT, Intvw CLNT, Submit CUST, Intvw CUST"
I really appreciate all the help. Below is the code that I have been working. Thank you!
Sub Copy_Rows_If()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Sheets("New York”, “California”, “Virginia ").Activate
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = 3 'Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If Sheets("New York”, “California”, “Virginia ").).Cells(Rows.Count, "status").Value = "Submit clnt" Then
Sheets("New York”, “California”, “Virginia ").).Rows(i).Copy
Sheets("Summary ").Rows(Lastrowa).PasteSpecial xlPasteValues
Lastrowa = Lastrowa + 1
End If
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
I'm really new in VBA. I tried to figure out this by myself using other codes I found online, but I have errors.
I have 4 sheets (New York, California, Virginia, and Summary). The first 3 have values in columns A to O.
I need a code to copy the complete row from the 3 sheets (New York, California, Virginia) and paste it in the next available row in sheet "Summary" based on the value in the column "STATUS" (Column N). If value is equal to one of the following "Submit CLNT, Intvw CLNT, Submit CUST, Intvw CUST" then copy to next available row in sheet "Summary".
Also, if possible, in the sheet “Summary” I need rows to be delete it if the value in the column "STATUS" in the 3 first sheets changes to any other than "Submit CLNT, Intvw CLNT, Submit CUST, Intvw CUST"
I really appreciate all the help. Below is the code that I have been working. Thank you!
Sub Copy_Rows_If()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Sheets("New York”, “California”, “Virginia ").Activate
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = 3 'Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To Lastrow
If Sheets("New York”, “California”, “Virginia ").).Cells(Rows.Count, "status").Value = "Submit clnt" Then
Sheets("New York”, “California”, “Virginia ").).Rows(i).Copy
Sheets("Summary ").Rows(Lastrowa).PasteSpecial xlPasteValues
Lastrowa = Lastrowa + 1
End If
Next
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub