LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default VBA Loop If statement

Good morning,

Please could someone help me with this. I currently have the following
piece of code in my workbook:
Sub ProdCheck()
Dim Answer As String
If Range("B2").Value = "ESX" Then
Range("AB2").Value = 10
'*****this is where the ELSEIF argument of the code should be*****
Else: Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "Does this product
exist?")
If Answer = vbNo Then
MsgBox "You pressed NO!"
Range("AB2").Value = 0
Else
MsgBox "You pressed Yes!"
Range("AB2").Value = 1000
End If
End If
End Sub

Whilst the code works, it has two issues with regards to what I am trying to
achieve:
1.) I need it to loop through the whole worksheet performing the if
statement. ie: not just row 2, but row 2-last row on worksheet

2.) in the IF statement itself, I need to include an ELSE IF (see commented
secion in code), and for the code to check whether the value in the cell "B"
it is checking is in ColumnA of worksheet2, and if so for "AB2" = 100, if not
- then continue to the ELSE part of the current code

Please can someone help with this, I am completely stuck

Really appreciate it

Regards,
 
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
for loop with if statement Steve Excel Worksheet Functions 1 February 17th 10 07:56 PM
Do i need a Next or Loop statement ? Corey Excel Programming 1 March 22nd 07 03:22 AM
loop Statement Nigel Excel Programming 0 April 4th 06 04:10 PM
If statement - Loop? George Excel Discussion (Misc queries) 1 March 14th 06 07:06 AM
Help with a loop VBA with an if statement kixelsid Excel Programming 10 February 28th 06 07:15 PM


All times are GMT +1. The time now is 02: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"