First, let me thank everyone with their help with various issues of my VBA Program.
Second, this isn't a problem more an inquiry of how to make things "cleaner" in writing my code.
What I am trying to do, using IF/THEN, is determine if a variable does NOT have a certain value, and if it doesn't, then to find the condition true.
The variable is a SKU that has a "-" in it in either the 5th, 6th, and 7th Character. I want to search the SKU and if it does NOT find the "-" in the SKU then to have the IF/THEN condition be true.
The only way I seem to be able to do this is the following way:
Code:
If Mid(rcdFindItemSKU, 6, 1) = "-" Or _
Mid(rcdFindItemSKU, 7, 1) = "-" Or _
Mid(rcdFindItemSKU, 8, 1) = "-" Then
Else
AddLetterTorcdFindItemSKU = ""
KeyCode = vbKeyShift
Exit Sub
End If
The original code was the following:
Code:
If Mid(rcdFindItemSKU, 6, 1) <> "-" Or _
Mid(rcdFindItemSKU, 7, 1) <> "-" Or _
Mid(rcdFindItemSKU, 8, 1) <> "-" Then
AddLetterTorcdFindItemSKU = ""
KeyCode = vbKeyShift
Exit Sub
End If
The problem with the above code is two of the conditions will always be TRUE because if the Dash is in character 6, then characters 7 and 8 will be TRUE.
Is there another way to write the logic so I don't to use the Else statement? Thanks.
Ken L