@mtplmtpl. the file you uploaded is meaningless. Where is the file you talked about in your initial post? Did you look at the example (Demo.xlsm) the Paul_Hossler kindly provided for you?
I seriously doubt that you did for if you had done so you will have seen a perfectly good example of a workbook upon opening loading a Userform1 and only showing the Userform. On that Userform is a Command Button which when clicked "calls" the Sub Hello module which simply displays a message "Hello!!".
If you haven't do so by now I request that you pause here and do so by saving Paul's file to your system, locate the file by using File Explorer, Double click on the file Demo.xlsm and click on the Command Button that is embedded on the Userform. This example does everything you asked for. When you are ready to try to understand the structure of the workbook, select Developer section ( Alt F11 in Microsoft systems I believe). The workbook contains a Userform1 and three modules. If you click on THisworkbook you will find the 1st, click on Userform1 to find the second, Click on Module1 to find the third.
Screen Shot 2022-05-01 at 10.24.24 am.jpg
Click on Thisworkbook to find the 1st module. It is this module which upon the workbook opening, loads and shows the Userform1.
Screen Shot 2022-05-01 at 10.26.26 am.jpg
Click on UserForm1 to find the second module, in which the command button function calls the Sub Hello()
Screen Shot 2022-05-01 at 10.24.47 am.jpg
Click on Module 1 to find the 3 section of code, namely the Sub Hello()
Screen Shot 2022-05-01 at 10.25.07 am.jpg
Once you have done this you should now understand where to place your sections of code, how to construct them, and the reasoning behind the structure.
In your very first post you talked about having constructed a Userform and a macro. Unless you are prepared to upload the workbook upon which you are attempting to design your Userform, we are very limited in giving you precise assistance.