Hi everyone,
I know this topic has already been discussed several times, but either none of the threads really answers my question or I just really dont get it - I'm sorry, my bad.
What I am trying to do: I have a workbook with several sheets called "project roadmap". The idea is to have one sheet as input/output form containing all project details, another one containing all data from all projects as a database. My sub "getfromdatabase" copies all necessary information from the database to the output form by storing the values of the database in the corresponding ranges of the form. That's working fine. The userform is loaded at the beginning of the sub to allow the user to choose which project should be loaded (by name or number).
So far, my cancel button action is just unload, but I want cancel to exit the whole "getfromdatabase" sub, so no values are going to be copied.
The main sub looks like this:
The cancel button action:
I already find the solution using a cancel as boolean and add an IF statement in the main sub. But honestly, I couldn't figure how and where to define the variable and/or private subs. Could you please help?
Many thanks!
Nika
I know this topic has already been discussed several times, but either none of the threads really answers my question or I just really dont get it - I'm sorry, my bad.
What I am trying to do: I have a workbook with several sheets called "project roadmap". The idea is to have one sheet as input/output form containing all project details, another one containing all data from all projects as a database. My sub "getfromdatabase" copies all necessary information from the database to the output form by storing the values of the database in the corresponding ranges of the form. That's working fine. The userform is loaded at the beginning of the sub to allow the user to choose which project should be loaded (by name or number).
So far, my cancel button action is just unload, but I want cancel to exit the whole "getfromdatabase" sub, so no values are going to be copied.
The main sub looks like this:
VBA Code:
Sub getfromdatabase()
Dim wb As Workbook: Set wb = ThisWorkbook
Dim form As Worksheet: Set form = wb.Worksheets("Form")
Dim database As Worksheet: Set database = wb.Worksheets("Database")
Dim milestones As Worksheet: Set milestones = wb.Worksheets("Milestones Overview")
'########## WHICH ONE SHOULD BE LOADED? ##########################
'Call Userform
frmLoadProject.Show
The cancel button action:
VBA Code:
Private Sub CancelButton_Click()
'close Userform
Unload Me
End Sub
I already find the solution using a cancel as boolean and add an IF statement in the main sub. But honestly, I couldn't figure how and where to define the variable and/or private subs. Could you please help?
Many thanks!
Nika