VBAAccountant
New Member
- Joined
- Jun 12, 2018
- Messages
- 15
Hello, it's been a while since I've posted or done a macro so I apologize if I'm a bit rusty. I am getting a runtime error 9 on the below VBA...it fails at the line in red. I am actually getting the desired results, I'm just not sure how to get rid of the error.
Sub Copy_Row_To_Sheet_Cell_Value()
Application.ScreenUpdating = False
Dim i As Long
Sheets("Attorney Credited List").Activate
Dim Lastrow As Long
Lastrow = Sheets("Attorney Credited List").Cells(Rows.Count, "C").End(xlUp).Row
Dim Lastrowa As Long
Dim ans As String
For i = 2 To Lastrow
ans = Cells(i, "C").Value
Lastrowa = Sheets(ans).Cells(Rows.Count, "C").End(xlUp).Row + 1
Rows(i).Copy Destination:=Sheets(ans).Rows(Lastrowa)
Next
Exit Sub
End Sub
Sub Copy_Row_To_Sheet_Cell_Value()
Application.ScreenUpdating = False
Dim i As Long
Sheets("Attorney Credited List").Activate
Dim Lastrow As Long
Lastrow = Sheets("Attorney Credited List").Cells(Rows.Count, "C").End(xlUp).Row
Dim Lastrowa As Long
Dim ans As String
For i = 2 To Lastrow
ans = Cells(i, "C").Value
Lastrowa = Sheets(ans).Cells(Rows.Count, "C").End(xlUp).Row + 1
Rows(i).Copy Destination:=Sheets(ans).Rows(Lastrowa)
Next
Exit Sub
End Sub