LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
Amanda
 
Posts: n/a
Default "If" statement using "And"

I am trying to use an "If" statement that also contains "And". Below is an
example of what I am trying to do:

Sub test()

If Sheets("Sheet 1").Range("A1").Value = "1" And _
Sheets("Sheet 1").Range("A2").Value = "Yes" Then
Sheets("Sheet 2").Select
ElseIf Sheets("Sheet 1").Range("A1").Value = "1" And _
Sheets("Sheet 1").Range("A2").Value = "No" Then
Sheets("Sheet 2").Select
Rows("1:2").Select
Selection.Delete Shift:=x1Up
End If

End Sub

Basically, if cell A1 says "1" I want it to select Sheet 2. And if cell A2
says Yes, I want it to leave Sheet 2 as is. If cell A2 says No, I want it to
delete a couple of lines in Sheet 2.

Can anyone please give me any pointers about what I am doing wrong.

Thanks heaps in advance!

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if then else statement also using "and" Amanda Excel Discussion (Misc queries) 2 November 9th 05 12:47 PM
The "IF" Statement JeremyH1982 Excel Worksheet Functions 1 October 18th 05 08:32 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
How do I fix a circular reference in a financial statement? drjayhawk25 Excel Discussion (Misc queries) 0 February 7th 05 05:19 PM


All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"