I am writing a code that goes through a given range of cells with a for each loop. if theses calls do not satisfy an if statement withing the "for each", i need to write the range of that cell on another sheet. Ex: cells A20 and A36 do not conform so I want to write A20 and36 on another sheet. this way i will have a list of all the cells that require attention.Here is my code below:
r = 5
Set sht1 = Sheets("DataSheet")
Set sht2 = Sheets("DiscrepancyReport")
On Error GoTo DiscrepancySheetError
sht2.Select
On Error GoTo DataSheetError
sht1.Select
On Error GoTo 0
lastr = ActiveSheet.range("A1").Offset(ActiveSheet.Rows.Count - 1, 0).End(xlUp).Row
lastr = lastr - 1
'Column 1: WP
Set colrg = range("A3:A" & lastr)
For Each cell In colrg
If (cell.Value) = 6.01 Or (cell.Value) = 6.03 Or (cell.Value) = 3.04 Or (cell.Value) = 6.27 Then
Else
'## The following line makes no sense but i wrote it so you understand what i want to do
currentcell.range.Copy Destination:=sht2.range("A" & r)
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Not a valid WP"
r = r + 1
End If
Next
Thanks ahead!