Hi,
Ive been this all night and really not getting far, Ive been trying other peoples code out, and everything I try just doesnt do anything, I really dont know where I am going wrong.
I have two worksheets, a parked report worksheet where all the data is contained in a table. A formula in column AG will display the text Condition 1, and another worksheet called Condition 1.
I am trying to get VB code to work which looks for the text Condition 1 in the AG column, and copy the entire row into the condition 1 worksheet.
ideally I would like it to check Column AG in the Parked Report, for Condition 1 text, match it to my maintenance worksheet F6:F7, and if it matches, copies the entire row of the park report where Condition 1 appears into row 2 of Condition 1 report, and loop until the end of the data is reached.
I got this but like many VB I tried tonight, doesnt do anything. Im completed stuck, any help would be gratefully recived.
thanks
David
Ive been this all night and really not getting far, Ive been trying other peoples code out, and everything I try just doesnt do anything, I really dont know where I am going wrong.
I have two worksheets, a parked report worksheet where all the data is contained in a table. A formula in column AG will display the text Condition 1, and another worksheet called Condition 1.
I am trying to get VB code to work which looks for the text Condition 1 in the AG column, and copy the entire row into the condition 1 worksheet.
ideally I would like it to check Column AG in the Parked Report, for Condition 1 text, match it to my maintenance worksheet F6:F7, and if it matches, copies the entire row of the park report where Condition 1 appears into row 2 of Condition 1 report, and loop until the end of the data is reached.
I got this but like many VB I tried tonight, doesnt do anything. Im completed stuck, any help would be gratefully recived.
VBA Code:
Sub check_condition()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Parked Report").UsedRange.Rows.Count
J = Worksheets("condition1").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Parked Report").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Parked Report").Range("AG2:AG" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Condition 1" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Parked Report6").Range("A" & J + 1)
' xRg(K).EntireRow.delete
If CStr(xRg(K).Value) = "condition1" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
thanks
David
Last edited by a moderator: