I have a commandbutton in my spreadsheet, that asks users to choose Yes or No. When Yes is clicked, a macro is called
Here is my code to do that (I think this code is ok):
The form should ideally be part of a macro that utilises the information entered in the form. This part of my FuncAlloJnl
macro opens the userform, and I also show the part of the code that uses information enetered in the form
My problem is that I can't find
(a) how to pause the macro until the userform is closed,
(b) how to unload the userform textboxes, close and reset the form and let the rest of the macro continue to run, and
(c) when the Close button on the userform is clicked a message box warning the user that the form inputs will be lost and that the macro FuncAllocJnl will be ended. User to confirm with OK/Cancel.
Can this be a part of the macro?
Here is my code to do that (I think this code is ok):
Code:
Private Sub CommandButton1_Click()
Dim Answer As VbMsgBoxResult
Answer = MsgBox("Existing data will be cleared. Are you sure?", vbYesNo, "Create Journal Template")
If Answer = vbYes Then
Call FuncAllocJnl
End If
End Sub
macro opens the userform, and I also show the part of the code that uses information enetered in the form
Code:
UserForm1.Show
With wsJournal
.Rows("7:" & Rows.Count).ClearContents
.Rows("7:" & Rows.Count).ClearFormats
.Cells(4, 3).Value = UserForm1.TextBox9
.Cells(4, 5) = UserForm1.TextBox6
.Cells(4, 6) = UserForm1.TextBox8
.Cells(4, 6).NumberFormat = "mm"
.Cells(4, 8).Value = UserForm1.TextBox10
End With
(a) how to pause the macro until the userform is closed,
(b) how to unload the userform textboxes, close and reset the form and let the rest of the macro continue to run, and
(c) when the Close button on the userform is clicked a message box warning the user that the form inputs will be lost and that the macro FuncAllocJnl will be ended. User to confirm with OK/Cancel.
Can this be a part of the macro?