IF statement doesn't give result

Warg63

New Member
Joined
Mar 9, 2018
Messages
2
Please help!!

I have the macro below to return a result in column 13, row 2. The result is based on selections in columns 10, 11 and 12 of the same row. The macro appears to run and doesn't show an error in the code, but no result appears. I've started and stared, but can't see the problem :banghead:

[
Private SubCommandButton21_Click()
Dim score1 AsString, score2 As String, Score3 As String, result As String, x As Integer

x = 2

Do WhileCells(x, 10).Value <> ""

score1 =Cells(x, 10).Value

score2 =Cells(x, 11).Value

Score3 =Cells(x, 12).Value


If score1>= "Y " And score2 >= "N" And Score3>= "" Then

result = "do this"

ElseIf score1>= "Y " And score2 >= "Y" AndScore3 >= "" Then

result = “do that"

ElseIf score1>= "N" And score2 >= "" And Score3 >="Y" Then

result = "do the other "

ElseIf score1>= "N" And score2 >= "" And Score3 >="N" Then

result = "do nowt"

End If

Cells(x,13).Value = result

x = x + 1

Loop

End Sub]
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Welcome to the Board!

It looks very odd to use Greater Than or Equal to (>=) with text and blank entries.
I would recommend using Equal To (=) or Not Equal to (<>) for text/blank entries.
Try making those changes.

If it still does not work, please do the following:
- list your conditions to us (in plain English)
- provide an example of the values in the cells you are checking, and your expected result
 
Upvote 0
Aaaaah! That makes sense! I did wonder if it was the blanks, but being a newbie couldn’t figure it out.

Thank you Joe4, I’ll give it a go and let you know.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top