If...Elseif msgbox statements

excelmacro

Board Regular
Joined
Apr 8, 2002
Messages
50
why is this not working?

Private Sub OK_Click()
If CC Then MsgBox ("You have selected Cost Center")
If CC_Prime Then MsgBox ("You have selected Prime")
Else
MsgBox ("You must click either Cost Center or Cost Center and Primes")
End
This message was edited by excelmacro on 2002-04-25 08:41
This message was edited by excelmacro on 2002-05-03 12:23
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this, you needed to use a block If..Then..Else: -

Private Sub OK_Click()
If CC Then MsgBox ("You have selected Cost Center")
If CC_Prime Then
MsgBox ("You have selected Prime")
Else
MsgBox ("You must click either Cost Center or Cost Center and Primes")
End
End If
End Sub
 
Upvote 0
now when i click on CC and then hit the ok button, it comes up with the msgbox "You have selected Cost Center" response, and then the msgbox "You must click either the Cost Center or Cost Center and Primes". It works fine though when i only check on CC_Prime or don't check either of CC or CC_Prime
 
Upvote 0
Try,

Private Sub OK_Click()
If CC Then
MsgBox ("You have selected Cost Center")
ElseIf CC_Prime Then
MsgBox ("You have selected Prime")
Else
MsgBox ("You must click either Cost Center or Cost Center and Primes")
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,391
Messages
6,119,239
Members
448,879
Latest member
VanGirl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top