View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default "If" statement using "And"


Hello Amanda,

You don't need the AND when sets are mutually exclusive. The only
effect A1 has is to select Sheet2. A2 will select Sheet2 if it is "No"
and then delete the lines you specfied. A1 has no effect on the outcome
of A2 and vice versa.

Sub test()

If Sheets("Sheet 1").Range("A1").Value = "1" Then
Sheets("Sheet 2").Select
End If

If Sheets("Sheet 1").Range("A2").Value = "No" Then
Sheets("sheet2").Select
Rows("1:2").Select
Selection.Delete Shift:=x1Up
End If

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=496314