Compile Error: Block If without End if
Whenever you have an "If" line that ends in "Then" you need an End If.
The exception to this rule is, when there is only 1 instruction to
perform when the If is "true" you can group the If and the instruction
on a single line. So your code might look like this:
Sub P()
If Range("K2:K999").Select = "02" Then Range("M2:M999").Select =
"FedEx Ground"
If Range("K2:K999").Select = "03" Then Range("M2:M999").Select =
"FedEx 2Day"
If Range("K2:K999").Select = "" Then Range("M2:M999").Select = ""
End Sub
Or, you could use Else If, like this:
Sub P()
If Range("K2:K999").Select = "02" Then
Range("M2:M999").Select = "FedEx Ground"
ElseIf Range("K2:K999").Select = "03" Then
Range("M2:M999").Select = "FedEx 2Day"
ElseIf Range("K2:K999").Select = "" Then
Range("M2:M999").Select = ""
End If
End Sub
Or, just because there are numerous ways to skin this cat, you could
use a CASE structure.
|