Loop Code

ddub25

Well-known Member
Joined
Jan 11, 2007
Messages
613
Office Version
  1. 2016
Platform
  1. Windows
Sub Ent1_1stBU()
Dim IsItFS As String
Dim P1NS As String
Dim P1WG As String
Dim Condition1 As String
Dim GS As String
Dim Condition2 As String

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

If IsItFS = "1st S" And P1NS = "NS" And P1WG = "W" Then
Condition1 = "Pass"
Else
Condition1 = "Fail"
End If

If GS = "GE" Then
Condition2 = "Pass"
Else
Condition2 = "Fail"
End If

If Condition1 = "Pass" And Condition2 = "Pass" Then
Range("CM73").Value = "Enter..."
Else
Range("CM73").Value = ""
End If
End Sub

I want this code to continuously be looping until it finds the conditions where it has to return a result of "Enter..." in CM73. At present I am running it manually myself. Can anyone help with that?
Note: Sorry I haven't used code tags, but I can't make any sense of the explanation of how to do it. If anyone could point me to a clear explanation, that would be helpful
 
Last edited:

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
ddub25,

Looping in what way, starting row 73 and then row by row until you get pass pass ?
If so what column would be a good test to determine the last row of data?

For code tags precede the code with the word code enclosed in square brackets [] and terminate with /code in square brackets
 
Upvote 0
I want the code to find the moment when,
IsItFS = "1st S" And P1NS = "NS" And P1WG = "W"
and then after it has checked for that and found those 3 conditions to be true, 1 second later, it needs to check to see if GS = "GE"

The reason why the code needs to first of all check that the initial 3 variables equal my requirements is because
when GS changes to = "GE", the 3 initial variables will no longer equal
(IsItFS = "1st S" And P1NS = "NS" And P1WG = "W")

When all these conditions are met, I want "Enter..." to be outputted into CM73
 
Upvote 0
Can anyone help with this? Does my explanation maybe not make sense?
 
Upvote 0
The code has slightly changed also, so I'll re-post it with code tags this time.

Code:
Sub Ent1_1stBU()
    Dim IsItFS As String
    Dim P1NS As String
    Dim P1WG As String
    Dim Condition1 As String
    Dim GS As String
    Dim Condition2 As String
    
    IsItFS = Range("CI73").Value
    P1NS = Range("CJ73").Value
    P1WG = Range("CK73").Value
    GS = Range("CL73").Value
    
    If IsItFS = "1st S" And P1NS = "NS" And P1WG = "W" Then
    Condition1 = "Pass"
    Else
    Condition1 = "Fail"
    End If
    
    If GS = "GE" Then
    Condition2 = "Pass"
    Else
    Condition2 = "Fail"
    End If
    
    If Condition1 = "Pass" And Condition2 = "Pass" Then
    Range("CN73").Value = "Enter..."
    Else
    Range("CN73").Value = "Wait.."
    End If
End Sub
[code/]
 
Last edited:
Upvote 0
the code tags don't seem to have worked, what have I done wrong?
 
Upvote 0

Forum statistics

Threads
1,203,067
Messages
6,053,334
Members
444,654
Latest member
Rich Cohen

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