Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to end my macro in If-else-Endif Tan New Users to Excel 1 April 6th 07 10:48 AM
#If #else #endif Carl-Rainer Zeiss Excel Programming 4 January 19th 06 12:20 PM
If, ElseIf mast Excel Programming 1 January 26th 05 12:11 PM
#if-then-#elseif-#endif Sheldon Excel Programming 0 November 2nd 04 08:44 PM
optimize cycle's speed - For, Next or DO, UNTIL; IF-THEN, ENDIF or CASE, ENDCASE Oleks Excel Programming 1 May 15th 04 01:52 PM


All times are GMT +1. The time now is 09:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"