VBE msgbox

mbrandt7279

New Member
Joined
Apr 12, 2013
Messages
2
I have a user form with 125 checkboxes and if checked would like them to display one message box containing a specific message for that the checkbox slection, but all messages in one message box.

I have one command button that will list each message box individually, using code like this -
If CheckBox12 = True And CheckBox5 = True Then MsgBox "You would need to see your manager"

Each message box individually is time consuming and it would be better if they all displayed in one box. Of the 125 check box options, 7 or 8 will only be selected at any given time.

Any help would be greatly appreciated, and thank you for your patience I have only been coding in VBE fo a week.

Thank you,
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi and welcome to the forum.
Maybe try something like this...

Code:
    [color=green]'Build a message string then display the one built up message in a message box[/color]
    [color=darkblue]Dim[/color] strMsg [color=darkblue]As[/color] [color=darkblue]String[/color]
    
    [color=darkblue]If[/color] CheckBox12 And CheckBox5 [color=darkblue]Then[/color] strMsg = strMsg & "You would need to see your manager" & vbLf & vbLf
    
    [color=darkblue]If[/color] CheckBox13 And CheckBox6 [color=darkblue]Then[/color] strMsg = strMsg & "You would need to do something else" & vbLf & vbLf
    
    [color=green]'[/color]
    [color=green]'[/color]
    [color=green]'[/color]
    
    [color=green]'Display one message box[/color]
    [color=darkblue]If[/color] Len(strMsg) > 0 [color=darkblue]Then[/color] MsgBox strMsg
 
Upvote 0
I'm trying to imagine how your userform displays, having 125 checkbox controls on it! Is there any way you can export the userform to a file that you can upload/attach so we can have a look? I can't help thinking there's a better approach than using 125 checkbox controls! I agree with AlphaFrog's suggestion to implement a StringBuilder methodology, but I'm not sold on using MsgBox.

I'm thinking a multi-select listbox (check style) with the messages displayed in a single adjacent scrollable control.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,978
Latest member
rrauni

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