• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to keep msgbox in front of userform

Hello,
My userform pops up in front of my spreadsheet and I'm able to manipulate data on the spreadsheet while the userform is open, which I like a lot. I've added some popup messages to my userform. The popup messages stay in front, which is good. However, if I have the userform on one monitor and the spreadsheet on another, the messages popup in front of the spreadsheet, not the userform. Is there code to make the messages stay in front of the userform regardless if the spreadsheet is in the background or not?
 
I tried the code you provided and nothing changed. I'm bummed because it seemed to work for the person on Excel Forum. I'm a novice, but the code doesn't mention the msgbox. To my inexperienced eyes, it seems to be adjusting the position of the userform?
 
Sorry you are not receiving the same results there.

With my single monitor I was able to specify the userform be centered on the screen, then the msgbox would visualize over the userform.

The userform must be "ShowModal = False" in the settings.

Paste in the UserForm :
Code:
Option Explicit

Private Sub UserForm_Initialize()
 Me.StartUpPosition = 0
    Me.Top = 325
    Me.Left = 600
End Sub

Paste in a Module connected to a CommandButton :

Code:
Option Explicit

Sub shwFrm()
    UserForm1.Show
    MsgBox "Hi"
End Sub

Sample workbook attached.

83286
 

Attachments

  • Book1.xlsm
    16.8 KB · Views: 6
I really appreciate your efforts. With the sample you provided, I'm not able to test it by 1. opening the userform, 2. move it to my other monitor, 3. take an action that results in a message box so I can see if it stays with the userform or not. When I click the button, the userform and the message box pops up simultaneously.

The command button to open my userform is on the Sheet1 module as follows:
Code:
Private Sub cmbDataEntry_Click()
MasterForm.Show
End Sub

The code to center the Userform in front of the worksheet is as follows:
Code:
Private Sub UserForm_Activate()
'Adjust UserForm size and center in front of Excel spreadsheet
With Me
.StartUpPosition = 0
.Height = 645
.Width = 700
.Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
 .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
End With
End Sub

All of this works perfectly. I just can't figure out how to keep the message box with the userform...yet.
 
I tried this, but the msgbox still stays in front of the worksheet, not the userform. If the userform is in front of the worksheet, it's not an issue. It's when I need the userform and the worksheet to be on different monitors is when I run into issues. When I enter data, I know this behavior and look for the message to pop up where the worksheet is. My concern is when others are accessing the userform.
 
@Yodelayheewho
I've been out of the loop forr 11 months.(I was in the hospital) I am a bit rusty.
I see your question isn't solved yet. I don't remember if there is a solution with msgboxes, but there is sure one when you make your own msgboxes with using homemade userforms that opens the correct custom userform and displays the messages that you want.
Here it is evening, time to eat and .....;)
But I can look at tommorrow.
I dont't have an example of your file and or code what would make ansering your question al lot
easier but I can make an example with custom made userforms.
Let say as example :):) In your userform , in textbox 1 the question is what is your name, if the textbox is filled with belle, then the name Lady pops up in your custom made userform popup, if the textbox is filled with yoydelay the name tramp pops up. (just using names from the disney film, lady and the tramp) These custum made userforrms stay at the same screen as the parent userform
 
Hi Belleke!
Welcome back!
I'm so sorry to hear you've not been well and in the hospital. I hope your on the mend.
It's funny that you mention making your own msgbox with a userform. I never heard of this until today when I saw a reference to it when searching for an answer. I would like to give this a try if we can make it perform like a 'regular' msgbox. Take your time, eat and rest...no rush.
 
Back
Top