It looks like you want to check each of those values in column K.
Option Explicit
Sub P2()
dim LastRow as long
dim iRow as long
with activesheet
lastrow = .cells(.rows.count,"K").end(xlup).row
for irow = 2 to lastrow
if .range("K" & irow).value = "02" then
.range("M" & irow).value = "FedEx Ground"
elseif .range("K" & irow).value = "03" then
.range("M" & irow).value = "FedEx 2Day"
elseif .range("K" & irow).value = "" then
.range("M" & irow).value = ""
end if
next irow
end with
End Sub
This actually looks for the Text "02" in the cell--not the number formatted to
have leading 0's.
That could be very important.
You may want to change:
if .range("K" & irow).value = "02" then
to
if .range("K" & irow).value = 2 then
(and same with "03" and 3)
wrote:
This is my first time using a Microsoft Excel Macro and I'm trying to
run the following code and keep getting the:
Compile Error: Block If without End if message and I can't figure out
why
Sub P()
'
' Macro1 Macro
' Changing FedEx Descriptions
'
' Keyboard Shortcut: Ctrl+Shift+X
'
If Range("K2:K999").Select = "02" Then
Range("M2:M999").Select = "FedEx Ground"
Else
If Range("K2:K999").Select = "03" Then
Range("M2:M999").Select = "FedEx 2Day"
Else
If Range("K2:K999").Select = "" Then
Range("M2:M999").Select = ""
End If
End Sub
--
Dave Peterson