macro for copying data from one sheet to another
Hello,
I am working on a macro to copy data from one sheet to another. There are four sheets on a workbook. I have "if condition" mentioned on column H of first sheet called Spreadsheet. If the condition is met it answers yes. I want to write a macro to copy rows A:E from sheet called Spreadsheet to sheet called Exception if condition on column H is met and it answers "yes" in column H of Spreadsheet. Data should be copied on cell A2 on Exceptions sheet. Here is what i have so far but it is not working. Please help. Thanks in advance for your time and help.
Sub CopyRowsAcross()
Dim i As Integer
Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("SPREADSHEET")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Exceptions")
For i = 2 To ws1.Range("H250000").End(xlUp).Row
If ws1.Cells(i, 8) = "Yes" Then ws1.Rows(i).Copy ws2.Rows(ws2.Cells(ws2.Rows.Count, 2).End(xlUp).Row + 1)
Next i
End Sub
Recent comments
5 years 36 weeks ago
6 years 22 weeks ago
6 years 34 weeks ago
6 years 37 weeks ago
6 years 38 weeks ago
6 years 43 weeks ago
6 years 52 weeks ago
7 years 2 days ago
7 years 3 days ago
7 years 3 days ago