I am trying to create a button in Excel using VBA code. The button will run VBA code to find all cells in column-D with a "Y" AND all cells in column-E with a "Y". If this statement is true, all corresponding cells in column-J will be replaced with a "Y". I have tried the following with no success:
Sub Simple_If()
If Range("D:D").Value = "Y" And Range("E:E").Value = "N" Then
Range("J:J").Value = "Y"
End If
End Sub
I have now tried the following code:
Dim x As Integer
With Sheets("Sheet2")
LastRow = .Range("D" & .Rows.Count).End(xlUp).Row
For x = 2 To LastRow
If Cells(x, 4).Value = "Y" And Cells(x, 5).Value = "N" Then
Cells(x, 10).Value = "Y"
Else
Cells(x, 10).Value = "N"
End If
Next x
End Sub
The new code does not edit the sheet based upon the conditions called, but I do not get errors? What is the problem here? Thank you for any help or guidance.