Hi,
I know this has been covered a lot but I just can't seem to get my VBA Code working.
I have a workbook that contains 5 sheets.
The sheet with data is called, "HOSPITAL SIT REGISTER" and the data is entered between B7:U61. The 'U' column is a formula that returns yes/no dependant on the entry of other values.
Where the answer is yes to 'U' I want it to copy the whole row into a second sheet, 'Datasets' from A18.
Currently I have this code set up;
It completes and comes up with "Done" but it is not giving the results and there is nothing on the Datasets page.Option Explicit
Sub copy_dbo()
Dim i As Long, lrow As Long
Application.ScreenUpdating = False
With Worksheets("HOSPITAL SIT REGISTER")
lrow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 2 To lrow
If .Range("U7:U61" & i).Value = "Yes" Then .Rows(i).Copy Worksheets("Datasets").Range("A18" & Rows.Count).End(xlUp).Offset(18, 0)
Next i
End With
MsgBox "Done"
Application.ScreenUpdating = True
End Sub
Also I believe I may have a problem once it works as I need it to clear any previous values each time before running this code.
Thanks
Bookmarks