IF statement error

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
617
Office Version
  1. 2019
Platform
  1. Windows
Sub Ent1()
Dim IsItFS As String
Dim P1NS As String
Dim P1WG As String
Dim GS As String

IsItFS = Range("CH73").Text
P1NS = Range("CI73").Text
P1WG = Range("CJ73").Text
GS = Range("CK73").Text

If IsItFS = "1stSet" And P1NoS = "NoSe" And P1Ga = "W" Then
MsgBox ("Pass")
Else
MsgBox ("Fail")
End If
End Sub

This code is outputting "Fail" in the message box when it should output "Pass" as the 3 IF's asked are true. Have I got the syntax wrong on the IF and AND part of this code?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Rich (BB code):
Sub Ent1()

	Dim IsItFS As String, P1NS As String, P1WG As String, GS As String

	IsItFS = Range("CH73").Value
	P1NS = Range("CI73").Value
	P1WG = Range("CJ73").Value
	GS = Range("CK73").Value

	If IsItFS = "1stSet" And P1NS = "NoSe" And P1WG = "W" Then
		MsgBox "Pass"
	Else
		MsgBox "Fail"
	End If

End Sub

edit: also, please use code tags when posting code. thanks :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,334
Members
449,077
Latest member
Jocksteriom

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