Hi there,
Newbie to VBA here, I have a VBA code where I can copy specific cells to a second worksheet when cell "AG" specifies "yes" which is all working fine. The cells I need copying over all transfer over fine but for some reason it is not copying it to the next available row, instead it is copying to which seems the middle of the worksheet (around row 300). Even if the second worksheet is completely empty (just headings on row 1) it will still copy to the middle.
Code below:
Sub s_move_completed_Live_cases_to_CG_ready()
Dim i_last_row_tbl_Live_cases As Integer, i_last_row_tbl_CG_ready As Integer
Dim i_curr_row_tbl_Live_cases As Integer
Dim int1 As Integer
Dim str1 As String
Sheets("CG ready ").Select
i_last_row_tbl_CG_ready = Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Live cases").Select
i_last_row_tbl_Live_cases = Cells(Rows.Count, "A").End(xlUp).Row
For int1 = i_last_row_tbl_Live_cases To 3 Step -1
str1 = Sheets("Live cases").Cells(int1, "AG").Value
If str1 = "yes" Then
i_last_row_tbl_CG_ready = i_last_row_tbl_CG_ready + 1
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "A").Value = Sheets("Live cases").Cells(int1, "A").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "B").Value = Sheets("Live cases").Cells(int1, "B").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "C").Value = Sheets("Live cases").Cells(int1, "C").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "D").Value = Sheets("Live cases").Cells(int1, "D").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "E").Value = Sheets("Live cases").Cells(int1, "E").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "F").Value = Sheets("Live cases").Cells(int1, "F").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "G").Value = Sheets("Live cases").Cells(int1, "G").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "H").Value = Sheets("Live cases").Cells(int1, "H").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "I").Value = Sheets("Live cases").Cells(int1, "i").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "J").Value = Sheets("Live cases").Cells(int1, "J").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "O").Value = Sheets("Live cases").Cells(int1, "K").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "P").Value = Sheets("Live cases").Cells(int1, "L").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "Q").Value = Sheets("Live cases").Cells(int1, "M").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "T").Value = Sheets("Live cases").Cells(int1, "AC").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "U").Value = Sheets("Live cases").Cells(int1, "AD").Value
Sheets("Live cases").Rows(int1).EntireRow.Delete
Else
End If
Next int1
End Sub
Any help would be much appreciated!
Newbie to VBA here, I have a VBA code where I can copy specific cells to a second worksheet when cell "AG" specifies "yes" which is all working fine. The cells I need copying over all transfer over fine but for some reason it is not copying it to the next available row, instead it is copying to which seems the middle of the worksheet (around row 300). Even if the second worksheet is completely empty (just headings on row 1) it will still copy to the middle.
Code below:
Sub s_move_completed_Live_cases_to_CG_ready()
Dim i_last_row_tbl_Live_cases As Integer, i_last_row_tbl_CG_ready As Integer
Dim i_curr_row_tbl_Live_cases As Integer
Dim int1 As Integer
Dim str1 As String
Sheets("CG ready ").Select
i_last_row_tbl_CG_ready = Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Live cases").Select
i_last_row_tbl_Live_cases = Cells(Rows.Count, "A").End(xlUp).Row
For int1 = i_last_row_tbl_Live_cases To 3 Step -1
str1 = Sheets("Live cases").Cells(int1, "AG").Value
If str1 = "yes" Then
i_last_row_tbl_CG_ready = i_last_row_tbl_CG_ready + 1
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "A").Value = Sheets("Live cases").Cells(int1, "A").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "B").Value = Sheets("Live cases").Cells(int1, "B").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "C").Value = Sheets("Live cases").Cells(int1, "C").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "D").Value = Sheets("Live cases").Cells(int1, "D").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "E").Value = Sheets("Live cases").Cells(int1, "E").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "F").Value = Sheets("Live cases").Cells(int1, "F").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "G").Value = Sheets("Live cases").Cells(int1, "G").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "H").Value = Sheets("Live cases").Cells(int1, "H").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "I").Value = Sheets("Live cases").Cells(int1, "i").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "J").Value = Sheets("Live cases").Cells(int1, "J").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "O").Value = Sheets("Live cases").Cells(int1, "K").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "P").Value = Sheets("Live cases").Cells(int1, "L").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "Q").Value = Sheets("Live cases").Cells(int1, "M").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "T").Value = Sheets("Live cases").Cells(int1, "AC").Value
Sheets("CG ready ").Cells(i_last_row_tbl_CG_ready, "U").Value = Sheets("Live cases").Cells(int1, "AD").Value
Sheets("Live cases").Rows(int1).EntireRow.Delete
Else
End If
Next int1
End Sub
Any help would be much appreciated!