Home |
Search |
Today's Posts |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel compile error. Only some computers? | Excel Discussion (Misc queries) | |||
compile error in hidden module: autoexecnew - how do I get rid? | Charts and Charting in Excel | |||
Compile error in hidden module | Excel Discussion (Misc queries) | |||
Compile Errors with Different versions of Excel | Excel Discussion (Misc queries) |