vbNo = Keep the VbForm Open

oyu0217

New Member
Joined
Jan 7, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hey people, How do I keep the VbForm open? Here's the goal. Form open > Is the data complete? Yes = Save If No, keep the form open to complete the details.

Private Sub QuestionForm_Save_Button_Click()

Dim answer As Integer
answer = MsgBox("Is the data complete? This is irreversible.", vbQuestion + vbYesNo + vbDefaultButton2)

If answer = vbYes Then
Sheets("Question Form Data").Select
Range("B1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("QuestionTable[[#Headers],['#]]").Select
ActiveCell = GuideName_Textbox
ActiveCell.Offset(0, 1) = ProductType_ListBox
ActiveCell.Offset(0, 2) = Questiondetails_TextBox
ActiveCell.Offset(1, 0).Select
Sheets("Menu").Select
MsgBox "Data has been saved"
Unload Question_Form

Else
MsgBox "Make sure to complete the form"
'Question_Form.I DONT KNOW WHAT TO DO TO KEEP IT OPEN
End

End If

End Sub

_________________

Private Sub QuestionForm_Cancel_Button_Click()
Unload Question_Form
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You don't have to do anything to keep it open. It will stay open until either the code or the user closes it. Your code does not need to be changed.
 
Upvote 0
Solution
Hey people, How do I keep the VbForm open? Here's the goal. Form open > Is the data complete? Yes = Save If No, keep the form open to complete the details.

Private Sub QuestionForm_Save_Button_Click()

Dim answer As Integer
answer = MsgBox("Is the data complete? This is irreversible.", vbQuestion + vbYesNo + vbDefaultButton2)

If answer = vbYes Then
Sheets("Question Form Data").Select
Range("B1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("QuestionTable[[#Headers],['#]]").Select
ActiveCell = GuideName_Textbox
ActiveCell.Offset(0, 1) = ProductType_ListBox
ActiveCell.Offset(0, 2) = Questiondetails_TextBox
ActiveCell.Offset(1, 0).Select
Sheets("Menu").Select
MsgBox "Data has been saved"
Unload Question_Form

Else
MsgBox "Make sure to complete the form"
'Question_Form.I DONT KNOW WHAT TO DO TO KEEP IT OPEN
End

End If

End Sub

_________________

Private Sub QuestionForm_Cancel_Button_Click()
Unload Question_Form
End Sub
I got it now its the freaking END after ELSE. My fingers has his own life ?
 
Upvote 0
My apologies, I read right past that. I have never used an End statement. Did that cause your form to close?!?
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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