If..Elseif...Else...EndIf
delete the undescores after then thens. this compiled for me
Sub SetUnitProduct()
Dim ReportUnit As String
If ActiveCell.Value Like "ACLG*" Or ActiveCell.Value = "IGATLB" Then
ReportUnit = "Large Balance"
ElseIf ActiveCell.Value = "ADU" Or ActiveCell.Value = "Deceased" _
Or ActiveCell.Value = "Litigation" Or ActiveCell.Value = "Pending Sale" _
Or ActiveCell.Value = "Replevin" Or ActiveCell.Value = "Sale" Or _
ActiveCell.Value = "WEF-Legacy" Then
ReportUnit = "Others"
ElseIf ActiveCell.Value Like "*Agency*" Or ActiveCell.Value Like "C*" Then
ReportUnit = "Agency"
ElseIf ActiveCell.Value Like "*Atty*" Or ActiveCell.Value Like "A*" Then
ReportUnit = "Attorney"
ElseIf ActiveCell.Value Like "I*" Then
ReportUnit = "Internal"
ElseIf ActiveCell.Value = "BANKRUPTCY" Or ActiveCell.Value = "DDA" Then
ReportUnit = "Rollup"
Else: MsgBox ("Unit not found.")
End If
MsgBox (ReportUnit)
End Sub
--
Gary
"StephanieH" wrote in message
...
I made some adjustments to what I posted early (thanks for everyone's help),
but now I'm getting a "Compile error: Else without If". It highlights the
section with the first Elseif statment. What am I doing wrong?
Sub SetUnitProduct()
Dim ReportUnit As String
If ActiveCell.Value Like "ACLG*" Or ActiveCell.Value = "IGATLB" Then _
ReportUnit = "Large Balance"
ElseIf ActiveCell.Value = "ADU" Or ActiveCell.Value = "Deceased" _
Or ActiveCell.Value = "Litigation" Or ActiveCell.Value = "Pending Sale" _
Or ActiveCell.Value = "Replevin" Or ActiveCell.Value = "Sale" Or _
ActiveCell.Value = "WEF-Legacy" Then _
ReportUnit = "Others"
ElseIf ActiveCell.Value Like "*Agency*" Or ActiveCell.Value Like "C*" Then _
ReportUnit = "Agency"
ElseIf ActiveCell.Value Like "*Atty*" Or ActiveCell.Value Like "A*" Then _
ReportUnit = "Attorney"
ElseIf ActiveCell.Value Like "I*" Then _
ReportUnit = "Internal"
ElseIf ActiveCell.Value = "BANKRUPTCY" Or ActiveCell.Value = "DDA" Then _
ReportUnit = "Rollup"
Else: MsgBox ("Unit not found.")
End If
MsgBox (ReportUnit)
End Sub
|