Hi friends,
I have below VBA to extract the row if matching criteria, but it is not working if criteria matches other than first row, please can have any change in the code
eg: if value greater than 5 in the AF18 it is working, if AF18 has value less than 5 and below there are cell greater than 5 code not working.
Sub COPYTO1()
Dim r As Range, sh As Worksheet
Set r = Worksheets("Extract").Range("AF18:AF200")
Set sh = Worksheets("1")
For Each cell In r
If (cell.Value) >= "5" Then
rw = sh.Cells(sh.Rows.count, "C").End(xlUp).Row + 1
cell.EntireRow.Copy
If rw < 18 Then rw = 18
sh.Cells(rw, 1).PasteSpecial xlValues
sh.Cells(rw, 1).PasteSpecial xlFormats
End If
Next
End Sub
Tanks
Abdul
I have below VBA to extract the row if matching criteria, but it is not working if criteria matches other than first row, please can have any change in the code
eg: if value greater than 5 in the AF18 it is working, if AF18 has value less than 5 and below there are cell greater than 5 code not working.
Sub COPYTO1()
Dim r As Range, sh As Worksheet
Set r = Worksheets("Extract").Range("AF18:AF200")
Set sh = Worksheets("1")
For Each cell In r
If (cell.Value) >= "5" Then
rw = sh.Cells(sh.Rows.count, "C").End(xlUp).Row + 1
cell.EntireRow.Copy
If rw < 18 Then rw = 18
sh.Cells(rw, 1).PasteSpecial xlValues
sh.Cells(rw, 1).PasteSpecial xlFormats
End If
Next
End Sub
Tanks
Abdul