Create Custom MsgBox in Excel VBA

KAMAL BHARAKHADA
KAMAL BHARAKHADA
5.9 هزار بار بازدید - 5 سال پیش - User wants to change the
User wants to change the text size and color of the MsgBox.

Well, I don't know whether it will happen with some core trick or not. but with this attached workbook I have easily demonstrated how msgbox can be developed with little efforts.

You required the following things

1. Userform
2. Label in the userform
3. One command button in the userform
4. change the label font and forecolor properties from the property window.
5. write the following code in the userform initialize event.

Private Sub UserForm_Initialize()
'user Form Code
UserForm1.Label1.Caption = Sheets("Sheet1").Range("B1").Value
End Sub

6. Put this code in the button

Private Sub CommandButton1_Click()
Unload UserForm1
Sheets("Sheet1").Range("B1").Value = vbNullString
End Sub

7. Now to test the msgbox... insert an ActiveX button from the insert in the developer tab. and assign the following code to it.

Private Sub CommandButton1_Click()
'button Code
Sheets("Sheet1").Range("B1").Value = "Your Current Date-Time Stamp is : " & vbNewLine & VBA.Format(VBA.Now, "DD-MMMM-YYYY HH:MM:SS AM/PM")
UserForm1.Show
End Sub

Now, get off from the design mode and click on the button and that's it. Hope it helps everyone who wants effective textboxes in their project than the typical one

Photos are attached in the comment section.

Thank you and try new things with it.

Kamal Bharakhda
5 سال پیش در تاریخ 1397/11/25 منتشر شده است.
5,924 بـار بازدید شده
... بیشتر