theprincipal78
Board Regular
- Joined
- Aug 5, 2009
- Messages
- 68
hi all
I have a userform with a command button which fires a macro.
everything works fine so far.
my problem is:
I would like to add a msgbox at the end of the macro which confirmes "successfully completed".
I cannnot simply add the msgbox at the end of the macro. don't know what I'm doing wrong.
(see below)
Private Sub CommandButtonOK_Click()
If Me.OptionButton1.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Government Securities"
ElseIf Me.OptionButton2.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Corporate Bonds"
ElseIf Me.OptionButton3.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Mortgage Market Instruments"
ElseIf Me.OptionButton4.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Money Market Securities"
ElseIf Me.OptionButton5.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "U.S. Municipal Bonds"
ElseIf Me.OptionButton6.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Preferred Securities"
ElseIf Me.OptionButton7.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Equities"
ElseIf Me.OptionButton8.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Commodities"
ElseIf Me.OptionButton9.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Indices"
ElseIf Me.OptionButton10.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Foreign Currency"
End If
Unload Me
Application.ScreenUpdating = False
Sheets("MySheet1").Select
Application.ScreenUpdating = False
'run macro
MyMacro1 (adds, hides and deletes various sheets)
MyMacro2
Application.ScreenUpdating = False
Sheets("MySheet1").Select
Range("A1").Select
'MsgBox "Successfully completed!"
End Sub
appreciate the help!
I have a userform with a command button which fires a macro.
everything works fine so far.
my problem is:
I would like to add a msgbox at the end of the macro which confirmes "successfully completed".
I cannnot simply add the msgbox at the end of the macro. don't know what I'm doing wrong.
(see below)
Private Sub CommandButtonOK_Click()
If Me.OptionButton1.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Government Securities"
ElseIf Me.OptionButton2.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Corporate Bonds"
ElseIf Me.OptionButton3.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Mortgage Market Instruments"
ElseIf Me.OptionButton4.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Money Market Securities"
ElseIf Me.OptionButton5.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "U.S. Municipal Bonds"
ElseIf Me.OptionButton6.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Preferred Securities"
ElseIf Me.OptionButton7.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Equities"
ElseIf Me.OptionButton8.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Commodities"
ElseIf Me.OptionButton9.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Indices"
ElseIf Me.OptionButton10.Value = True Then
ThisWorkbook.Worksheets("PropertyWorksheet").Range("A1").Value = "Foreign Currency"
End If
Unload Me
Application.ScreenUpdating = False
Sheets("MySheet1").Select
Application.ScreenUpdating = False
'run macro
MyMacro1 (adds, hides and deletes various sheets)
MyMacro2
Application.ScreenUpdating = False
Sheets("MySheet1").Select
Range("A1").Select
'MsgBox "Successfully completed!"
End Sub
appreciate the help!