I'm trying to make a macro check for a value in a cell and then do a procedure when that value is present and a different procedure when it is absent down a series of rows. Endstate is for the macro to select one of about a dozen different procedures (so a dozen different values) each with about 50 steps in an external program. These procedures would correspond to the letter in the independent cell for each row.
Below is a simplified version of the code I wrote to try the concept. The problem is that it only checks for the value once and doesn't switch procedures based on the presence or absence of the value. I've also tried If... Then... Else but had the same problem. Given what I intend to do, I think If... Then... Else would be preferable but I'm not sure.
These are the results I get for different values:
So it doesn't loop back to check the first Do While. I need it to keep checking for an unknown number of rows.
Can anyone help me?
Thanks
Below is a simplified version of the code I wrote to try the concept. The problem is that it only checks for the value once and doesn't switch procedures based on the presence or absence of the value. I've also tried If... Then... Else but had the same problem. Given what I intend to do, I think If... Then... Else would be preferable but I'm not sure.
Code:
Sub test() Z = 10 Do Until IsEmpty(Cells(Z, 1)) Do While Not IsEmpty(Cells(Z, 2)) Cells(Z, 3) = "YES" Z = Z + 1 Loop Do While IsEmpty(Cells(Z, 2)) Cells(Z, 3) = "NO" Z = Z + 1 Loop Z = Z + 1 Loop End Sub
These are the results I get for different values:
Code:
1 NO 2 Y 3 NO 4 Y
Code:
1 Y YES 2 Y YES 3 NO 4 Y
Can anyone help me?
Thanks
Comment