Hi,
Looking for the correct way to translate =countif(u2r,cellvalue) to vba. u2r being a named range.
I currently have the following which has been bodged into different variations.
[pre]
[/pre]
Thanks in advance.
Looking for the correct way to translate =countif(u2r,cellvalue) to vba. u2r being a named range.
I currently have the following which has been bodged into different variations.
[pre]
Code:
Dim numRows As Integer
Dim c As Double
Range("A1").Select
numRows = ActiveCell.CurrentRegion.Rows.Count
For r = 2 To numRows
CelVal = Worksheets("Sheet1").Cells(r, 2).Value
c = Application.WorksheetFunction.CountIf(u2r, CelVal)
If c = 0 Then
Range("A" & r & ":I" & r).Copy
Sheets("Sheet2").Select
NextRow = Range("A65536").End(xlUp).Row + 1
Range("A" & NextRow).Select
ActiveSheet.Paste
Sheets("Sheet1").Select
End If
Next r
Thanks in advance.