You have a few things wrong with your code and, because we do not know what the code is supposed to be doing, it is impossible to fix perfectly for you... but we can guide you to a solution. First off, Excel Fox has shown you where to place all of the required "End If" statements. Mind you, his placements are only a guess based on the apparent structure your code seemed to possess, but I think he got it right EXCEPT possibly for the placement of the last "End If". This is what Excel Fox suggested for it...
Code:
If ((class = "MMR_High" & netWDay <= 5)) Then
Classification = "Within SLA"
Else
Classification = "Beyond SLA"
Range("AM2:AM500").Value = class
Range("AL2:AL500").Value = classification2
End If
End Sub
It is impossible for us to tell positively where the lines of code I highlighted in red are supposed to be located, but I think this is a more logical arrangement for them give the code that proceed it...
Code:
If ((class = "MMR_High" & netWDay <= 5)) Then
Classification = "Within SLA"
Else
Classification = "Beyond SLA"
End If
Range("AM2:AM500").Value = class
Range("AL2:AL500").Value = classification2
End Sub
Unfortunately, that is not the only thing I see wrong with your code. First, you declared your 'classification2' variable as Integer, but then within your code you assign "Within SLA" to it... since "Within SLA" is text, you should declare the variable as String, not Integer. Next, I think everyone of your If..Then statement lines are incorrect. You wrote something similar to this for each one of them...
Code:
If ((Classification = "Reorganization" & netWDay <= 5)) Then
I think you meant the & sign to be the logical operator And. If I am right, you need to change every one of your If..Then statements so that it looks like this...
Code:
If (Classification = "Reorganization") And (netWDay <= 5) Then
Now, about the values being assigned to your variables. You assign values to the 'Classification' variable, but then you never assign the 'Classification' variable to anything meaning the values you assigned to it are lost with being used when your code ends. You do assign the 'class' variable to the range AM2:AM500 at the end, but only assign a value to it once within one of the If..Then statement... if that If..Then statement is not True during the running of your code, then nothing gets assigned to AM2:AM500 which, might possibly be what you intended, but my gut tells me that no, that is not what you ultimately wanted. As I said at the beginning, without knowing the actual intent of your code, it is impossible to say which of what I pointed out above really applies or not, but I have offered you my observation so you can take a more critical look at what you are doing inside your code.
Bookmarks