UserForm Initialize Code Closes UserForm
When I run the userform initialize procedure to reset the values in text boxes and the like instead of resetting like it should, now it closes the userform completely and then won't allow me to show it again, what could be the problem?
Private Sub UserForm_Initialize()
Me.MultiPage1.Value = 0
TextBox3.Value = ActiveWorkbook. Sheets("Sales Invoice"). Range("G15").Value
Dim hWndForm As Long
Dim hMenu As Long
hWndForm = FindWindow("ThunderDFrame", Me.Caption) 'XL2000
hMenu = GetSystemMenu(hWndForm, 0)
DeleteMenu hMenu, SC_CLOSE, 0&
The Dim stuff down is to gray out the x button, there are also some module level declarations to go with that...
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const SC_CLOSE As Long = &HF060
the userform shows when the workbook opens and is then hidden when the user has finished entering values, then when the user goes through the process of being asked to print and save, they are then asked if they would like to create a new record, if yes then it shows the userform again, but the userform is still filled with all the stuff previously entered. I tried using the unload me instead of hiding and that wouldn't work at all, didn't give errors just didn't show the userform either, this at least shows the userform, but now when the user goes to clear the information by initializing the userform again, it simply closes the userform and then it can't be shown again either.
This is the link to the ZIP, and here are some instructions for setting it up to work.
The contents of this need to be unzipped into a folder called SyntheticShield that is placed in the C: drive that way all paths begin with C:SyntheticShield and then the other folders or files will be referenced correctly. The template I'm having problems with is the SyntheticShieldInvoiceMaker template, when you open it you'll be prompted whether you want to create a new invoice, number is final blah blah blah, say yes, then it will ask if you are importing from the Quotemaker which you aren't say no, it should then show the userform as it should. Then you can go through that process and by pressing either the create invoice or go to template directly whatever, you can hide the userform. Then you press the command button (red) a userform is brought up asking if you'd like to save without emailing, save with emailing or close controls, as for right now, I'm just getting the save without emailing to work the rest is all the same just a few tidbits of code. So click save without emailing, it should then prompt an are you sure message box, click yes it will do some things, then it will ask if you want to print, click no, then it will ask do you want to create a new invoice, click yes, this should then start the process all over again by calling the workbook_open procedure, however, when you go through everything, and click no to the import from quotemaker part it won't show the userform. And at one point it would, but then I couldn't initialize the userform without it disappearing and not being allowed to be shown...I tried putting a command button on the template to show the userform, but it wouldn't do it either.
View Complete Thread with Replies
Related Forum Messages:
Creating A Checkbox On Userform Initialize And Then Using It In A Later Code
I have a userform that creates labels and checkboxes for those lables on the initialize event based on an if statement. I would keep getting an error on a line where I try and use the name of one of those created checkboxes of "variable not defined" as if it hasn't been created, but it was.. Here is the code for the creation:
Private Sub UserForm_Initialize()
'dynamically add the tickers and funds based on if there is any data inputs for them.
Dim lbl As MSForms.Label
Dim i As Integer
Dim x As Integer
Dim newcheckbox As MSForms.CheckBox
'selects the summary page
For i = 7 To 65
If Cells(i, 3) "" Then..................
Userform Loads Combobox Values Upon Userform Initialize
I have one userform that loads combobox values upon userform Initialize. Though through a second userform changes can be made to anotherworkbook this workbook is saves any changes. when i close the second userform i need to rerun the 1st userform Initialize event to update the combobox's incase changes have been made.
I have the following in a standard module:
Public Sub Timesht()
And this in my UserForm module:
Private Sub UserForm_Initialize()
Sheet1.Range("K5", Sheet1.Range("K65536").End(xlUp)).Name = "CODE"
userform1.ComboBox1.RowSource = "DATA BASE!CODE"
I have a named range as "CODE" in my DATA BASE!, sheet1.
I keep getting an error: " 380: Could not set the RowSource property. Invalid property value."
when I type in UserForm1 and arrow down. in turns into lowercase letters.
UserForm Initialize Error 13
The initialization code of a userform I'm using has started causing me 'Runtime Error 13, Type Missmatch' and I can't figure out why. Can anyone see a reason why I may be experiencing this,
Private Sub UserForm_Initialize()
'Get Last Entry
Dim countnonblank As Integer, myRange As Range
Dim SDate As Date, SDateRange As String, EDate As Date
Dim SDateString As String, EDateString As String, DirString As String
'count cells with data in them
Set myRange = Sheets("textfilemerger").Range("A:A")
countnonblank = Application.WorksheetFunction.CountA(myRange)
'decide if data is present or not
If countnonblank = 1 Then.............................
Userform Loading With Database Closes Workbooks
Userform Loading with database turns to close all Excelworkbooks completely
Database created in Excel worksheets to load and show in various different objects on userform. At present this project file size is approximately 2.5 mb and more to go as it is not yet complete. Now you can imagine how much big this project can be.
It uses various different types of objects such as listboxes with many columns, combo-boxes, textbox, checkbox and many. Every objects has its own style to display data on userform which is set in its properties itself.
Before loading userform to display, program creates database from manual entry (which is made by user on their working sheets) to database entry sheets (which is made to make compatible to show on userform). Upon loading, it also loads/populate all datas required in their objects to display.
All works perfect when I am in editing mode. It doesn't matter how big the database can be and works as required. This Project is now Password Protected and distributed among all staffs in our company to work with.
Error Occurs, when I tested in non-editing mode. The moment I triggered the macro to load the program, it takes some few times and pops-up with Excel Recover error message box asking whether to send Error Report and to whether recover & start Excel application again??
I don't know what is wrong. Sometimes it also run successfully when in non-editing mode even there is no changes in program codes.??
Sometimes I feel there can be a virtual memory issue, but my Pc is more than enough with 1GB ram. I hv also increased virtual memory limits and tested but all vain attempt...
Set Focus To TextBox On UserForm Initialize
I am trying to SetFocus on a single textbox in a simple form. I am not sure if I am doing it right.
Private Sub UserForm_Initialize()
' On Error Resume Next
' Dim rheadings, cl As Range
' Set rheadings = Worksheets("CONTACT").Range("A1:F1")
' For Each cl In rheadings
' Me.cbxSearchWhere.AddItem cl.Value
' Next cl
Kind regards, Mentor Auto Merged Post Until 24 Hrs Passes;Hi: I answered my own query - just commented out the setfocus instruction and it defaults to the first, and only, textbox by default
Set Up Multi Page To Mimic Userform Initialize
I have a userform that has a multi page on it with 4 pages. I notice that there is no way to have the individual pages be set to a click event- or none that I see anyways.
What I am wanting is for a series of events to happen based on what page the user chooses from the four (like a userform initialize type event).
Macro That Deletes Sheet With Control & Shows UserForm Causes UserForm To Disappear
This is weird - if you delete a sheet that contained a control then
a. showing a modeless userform resluts in a userofrm that goes invisible at subroutine End
b. public variables lose their value
These things do not happen if the sheet did not contain a control. Attached is an example file - put the inputfile.xls in your default file location (or add a path in the code) then open the ProblemDemo.xls and run the main macro to see it fal - isthis another Excelbug I've found?
Code For UserForm
I am finishing a travel per diem form and I want to implement a user form where the current rates could be entered by the user and update specific cells used as my drop down list values. I have made the form and a box that activates it. I just can't write the code to place the inputted data from the form into specific cells on a sheet so the list boxes will have the current rates to choose from. I can only find information to have the data populate the next blank row of a table.
Userform Textbox Code
I have a userform and I want a textbox that counts cells J7,M7,P7,S7,V7. Does anyone know how to write this code and where to put it. All I want is the textbox to show how many cells of these five have data in them and I want it to update automatically.
Build A UserForm From Code
Is it possible to build a simple input dialog box with only code?
I'd really like to avoid having a userform permanently in the project.
Ideally it would either display and be dismissed with code only, or be constructed as a real userform, displayed and dismissed, then deleted from the project afterwards.
I am aware of excel's built-in input dialog box, but I'd really like to get away from it's awkward keyboard functionality if it's somehow possible to do. Although that would be ideal if there were some way to make the textbox's behavior to the Home, End, Tab and arrow keys more like that of a normal textbox, but I am unaware of any such options.
Combo Box Code In Userform
I'm a rookie with combo boxes. This is my first one.
I need a pull-down list on a form that has the integers 1 to 40. Seems simple enough, but how do I add the integers to the combo box? I don't see a property to define the list.
I have the integers on a sheet called locked and the range is Y3:Y42 if that is required.
Also, I want the default value for the combo box to be 12 if that is possible.
The form is called frmNewData and the combo box is called cboAWG
Add Controls To UserForm With Code
way to allow a user to add a control to a userform without going into the VBE. Here is the situation, I am developing a userform to calculate a projected budget. I want the user to be able to select the number of controls to add, and click a command button to add them. Based on other selections that the user makes, different controls would automatically be added. Is this possible? As a follow up, will I be able to atttach code to these new controls?
Userform: Run Code Under Another Event
In a Userform, is there a way to run code that's listed under another UserForm event subroutine?
I have a Listbox and several Labels. When I click on a selection in the listbox, it populates the labels with various data from a spreadsheet. This code is in a "list_AfterUpdate()" subroutine.
If I change a piece of data and click a CommandButton1, I would like the labels to automatically update.
The only way I can think to do that (at present) is to run the code listed in the "list_AfterUpdate()" subroutine.
Is there a way to run that code without duplicating it in the "CommandButton1_Click" subroutine?
Unload Active Userform And Show New Userform
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Application.ScreenUpdating = True
Cancel = True
Trying to use above code to unload active userform and show new userform when red X (close) selected by operator. With the code as is, the Unload Me leaves the form on the screen and displays the RestrictedOptions form. If i remove the Restrictedoptions.Show, the Unload Me does remove the original form.
Change Values Of Labels In A Userform Through Another Userform
I'm trying to do: Let's say I have a simple userform with labels as follows:
(Label1) John's birthday: (Label2) 12.10.1974
(Label3) Mary's birthday: (Label4) 15.03.1978
(Button1) Change Birthdays
Let's say want to change the birthdays I see, so I press the button and enter the new values through another userform with inputboxes.
How do I make that change permanent, so that next time I start the macro in the labels 2 and 4 I have the last entered values for the birthdays???
Fill UserForm ListBox & Show Userform
having trouble with the details of actually making these features work for me. I figured out how to create a UserForm with a ListBox and 2 buttons, but I don't know how to proceed from here.
1. Populate the ListBox in the UserForm with a list of names from the sheet "Totals_Dropdowns", cells K2:K11
2. Make the UserForm pop up and enter the user's selection into cell C40 of the "Regenerate Request"
I know these are very basic operations, and I'm pretty sure I can figure out the rest of my problems once I can get past the above.
Userform Initialization Code Bombing
Private Sub UserForm_Initialize()
' MsgBox "removing outlines"
'OGA Mechanical Schemtic
Me.Label3.BorderStyle = fmBorderStyleNone '0821-1
Me.Label463.BorderStyle = fmBorderStyleNone 'Nitrogen Purge ORU
'OGA electrical Schematic
Me.Label447.BorderStyle = fmBorderStyleNone 'Hydrogen ORU
Me.Label184.BorderStyle = fmBorderStyleNone '0321-1
Me.Label468.BorderStyle = fmBorderStyleNone 'A301W1...............
Creating UserForm Controls Via Code
I'm making a form in excel to retrieve a number of welds. This number needs to be passed on to the next form to dynamically create an identical number of input fields (a set of text boxes and labels essentially). Any ideas on how I might do this? Is it even possible? I would like to avoid having 100 (my assumed maximum, it could get changed) sets of input fields and hiding the unused ones,
Update Code On A UserForm Via Macro
I have a time sheet which is used by around 15 people. Part of the timesheet is a userform which adds a new sheet and names it with the seleted month and year. I have made a few changes to my timesheet which I wish to update on other peoples sheets. I am going to send out a speadsheet with a macro that people can run and it will automatically make the changes to their timesheet. I have done all the work for updating the various formats and formuals but I have hit a bit of a brick wall when trying to change the code on a user form via a macro.
It would be great if I could either overwrite all of it or add a some lines of code from a specific line number.
VBA UserForm Code Causes Intermittent Freezing
I have a multipage userform with about 7 pages. When page 5 is activated, it caused excel to completely lock up. This does not happen everytime but randomly, and I can't seem to figure out what is causing this.
Here is the code -
If Me.MultiPage1.Value = 5 Then
If Not Range("A46").Text = "" Then
frmpricingtemplate.Label29.Visible = True
frmpricingtemplate.TextBox46.Visible = True
frmpricingtemplate.Label29.Caption = Range("A46").Text
Adding Code To A Userform At Run-time
The ultimate goal is to create a Userform at run-time.
The problem is writing event code for that Userform.
The current situation is:
I have a userform. (Created with the VBE, not at run-time.) There is one command button on that userform. The code module for that userform is this
Option Explicit ...
GIF Not Visible On UserForm While Code Runs
I have some code to put a GIF animation into a web browser on a userform. This works fine - on its own. However, once the GIF has loaded I want to run a whole bunch of code in the background. If I run the code all at once, the userform appears but the picture doest show - but when I place a breakpoint between loading the userform and the main sub routine of my code - the GIF loads and the animation is shown all the time my code is running in the backgorund.
Code Stops When UserForm Shows
I am attempting to show a User Form during the forms Initialize code. I Load the form after extracting data from a SQL Server database. The code that Loads the form is returned to after the form closes. The problem is that when I run through the Initialize code where criteria decides whether the form is actually shown to the user. If the criteria is not met there are no issue, but if the criteria is met, then the form is opened and the rest of the Initialize code is not stepped through. As there are many If Then and a Select Case and a couple With...'s I need the rest of the Initialized code to be stepped through so after the form is closed by the user and the original code which Loaded the form is returned to I do not get an error.
Oh and the big problem is that I am not getting an error message during this, the Load code is actually repeated because when the original code is actually returned to is returned on the Load UserForm code.
Private Sub UserForm_Initialize()
Dim i As Integer, Endofdata As Integer, wsheet3 As Worksheet, wbBook As Workbook
Dim wsSheet As Worksheet, c As Variant, gTotal As Long, Score As String, g3000 As Long
Dim gTotalAdd As Integer
On Error Goto ErrorHandler:
Application. ScreenUpdating = False
'cmbIDCountry.ColumnCount = 2
Set wbBook = ThisWorkbook
Set wsheet3 = wbBook.Worksheets("UpdateDetails")
Set wsSheet = wbBook.Worksheets("Data") ....................
Code Stops When UserForm Shown
I have an Access program that acts as a dashboard to open Excel reports. One of the Excel workbooks opens a form in the Auto_Open routine. My problem is that control is never passed back to access after the form opens. It appears that the code stops executing until the userform is closed. How can I open the excel workbook, show the Excel userform, and continue processing my Access code?
Set XL = Excel.Application
.Workbooks.Open FileName:=FileName, ReadOnly:=True
. ActiveWorkbook.RunAutoMacros xlAutoOpen
XL.Visible = True
' Excel Code
' The code get "stuck" right here
Global Code For UserForm Controls
Im using the following code on a userform to link the spinner and a textbox:
Private Sub Marketing_spn1_Change()
'ensures the text box changes when spinner is changed
Marketing_txt1.Text = Marketing_spn1.Value
Private Sub Marketing_txt1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
' ensure value typed in is valid
newvalue = Round(Val(Marketing_txt1.Text), 0)
If newvalue < Marketing_spn1.Min Then newvalue = Marketing_spn1.Min
If newvalue > Marketing_spn1.Max Then newvalue = Marketing_spn1.Max
' set the spinner value to keep in step with new value
Marketing_spn1.Value = newvalue
' set the textbox to the appropriate value
Marketing_txt1.Value = newvalue
I have many spinners and textboxes with the same name (marketing_txt2, marketing_spn3 etc) on both this userform and on other userforms I shall be doing.
Is there any way of just writing this code once, rather than copying and pasting it for each spinner/textbox?
Userform Command Buttons Do Not Carry Out The Code
I have recently obtained some help on code to bring up a user form based on cell change selection.
the code is as follows:
Dim c As Range
If Not Intersect(Target, Range("C6")) Is Nothing Then
With Sheets("Data Set").Range("D4:D43")
Set c = .Find(Range("C6").Value, LookIn:=xlValues)
If Not c Is Nothing Then
It brings up userform4, but the command buttons do not carry out the code behind them:
Private Sub CommandButton2_Click()
Sheets("Data Entry Form").Range("$C$6") = "Choose Employee"
If I run user form seperate from the sheet and bring it up only in visual basic, it works...Any ideas???
PS this command button is no so it resets field C6. The other button is yes and performs copy paste function. Neither are operational when user form is brought up through the sheet change. Only works when initialized in VB.
Force Code To Wait Until Userform Is Closed
At two places in the middle of my code I need to specify a particular variable; usually this is done by some autodection-method, but whenever this fails a userform gets loaded and the user needs to do some clicks which finally specifies that variable.
So far my code does NOT wait for the userform (and the user-input), but continues running until it fails, cause that particular variable (see above) had not been initialised with the correct value for this run.
How can I force the code to wait until the userform has been closed? Or what other way do you usually solve that problem when wanting to use a userform in mid-code? Below you find the place where I load the User form 'UsrFormSpecifyFormat' ....
Dynamic Userforms :: Code That Changes The Height Of A Userform
I am looking for some code that dynamically (during processing) changes the height of a userform. What I am trying to do is this: I have ten worksheets but only five are being used. I am looking to have a userform with a checkbox for each of the active sheets labeled. I don't want to have to display a form that is basically ten checkboxes with five enabled and five disabled. I want to show only the five active sheets checkboxes with a userform only large enough for the five. If six are active then a userform displaying six checkboxes and a userform large enough for only the six to be displayed.
Several Similar Statements In Different Events In My UserForm Code
I have several similar statements in different events in my UserForm code. Is it possible to separate these statements in a procedure and call it each it when I need it? The similar statements are:
For Each rw In .Range("A2:A" & .Range("A" & Rows.Count).End(xlUp).Row)
If ListBox5.List(, 4) = Trim(rw.Value) Then
Label1.Caption = rw.Offset(, 1).Value
Label2.Caption = rw.Offset(, 4).Value
Label3.Caption = rw.Offset(, 5).Value
If it's not possible to make my code shorter with a procedure, can I optimize somehow this repeated code?
Delete Splash Screen UserForm & Code
Some time ago (not sure how long ago) I created a splash screen that comes up when I first load a particular workbook. There was only one worksheet in the workbook and at that time the data in the worksheet was not so relevant and hardly ever used. That workbook name is "Employees" and the worksheet name is "EmpData".
Subsequently, the worksheet ("EmpData") in the workbook "Employees" has became relevant to a new workbook named "Payroll" I created. This workbook is used all the time. It had four different active worksheets.
I realized last week that the data in "EmpData" was very relevant to the work in the "Payroll" workbook so I copied "EmpData" worksheet in it's entirety to the "Payroll" workbook as a fifth worksheet using the same name as before, "EmpData". Now each time I open the "payroll" workbook the splash screen shows up and hangs around for several seconds or longer. It has become quite irritating and I want to delete it.
Code To Update Specific Data Via UserForm
I have a sheet with names and subdividers (Ent, Ver) on the columns, and dates on the rows. I am trying to make a form update the sheet when the name, ent or ver, and date match. I have attached a copy of my sheet to help explain that. I don't know much vba, but I can make a userform just fine. Trouble with most places is that the userforms only update based on empty cells, not based on more complex criteria.
Macro Stops At 1st Line Of Userform Code
I have built a small userform with 3 fields. The macro ran OK first few times. Now, when user enters data in the form and clicks OK nothing happens. I found that repeated clicking on OK or Cancel button on form had no effect. I then observed that VBA editor was open and the yellow cursor was displayed on the first code line under cmdOK_click procedure. The code line was also highlighted in yellow. There are no errors to debug and no break points etc. When I clicked the Run (or Continue) icon from the VBA toolbar, the macro completed OK. Question: Why is the macro pausing on the first line and how can I make it run without pausing for no apparent reason.
Create UserForm With Controls Via Macro Code
This code create a userform on the workbook opening .I'm having problems with
1. Closeing the Visual basic window after this procedure runs
2. Being able to use the create userformstext box value in other procedures
3. how to delete the userform on close
Dim objVBProj As VBProject
Dim objVBComp As VBComponent
Dim objVBFrm As UserForm
Dim objChkBox As Object
Dim x As Integer
Dim strCode As String
Dim firstLine As Long, SecondLine As Long
Set objVBProj = Application.VBE.ActiveVBProject
Set objVBComp = objVBProj.VBComponents.Add(vbext_ct_MSForm)
. Name = "InputRequest"
. Properties("Width") = 200
.Properties("Height") = 100......................
Place Code Behind Userform: Active Control Colored
I have created a user form and I am trying to get the active control colored. I am using the code from Mr Excel's VBA book - starts on page 454, and I have entered all the code, but now when I activate the user form I get an error ....."Compile Error. Invalid attribute in Sub or Function." and when I click OK, it takes me to this line of code.....
Private WithEvents objForm As clsCtlColor
In the book, this is where I am supposed to start entering the code "behind the userform" rather than in the class module. So, I assume this means that this code goes with all the other code for the user form (in VBA project click on form, then view code). Am I wrong? Should I be adding a module? Not sure what I am doing wrong.
Here is the code I have in the class module....
Public Event GetFocus()
Public Event LostFocus(ByVal strCtrl As String)
Private strPreCtr As String
Public Sub CheckActiveCtrl(objForm As MSForms.UserForm).......
To Create A Userform With A Textbox To Enter A Product Code
i would like to create a userform with a textbox to enter a product code , a command button to run VBA and a big text box to show output of VBA from Textbox 1 which i will connect to DB and pull back information relevant to that product code , is this possible i can create the userform no problem and already have code to pull back from DB into Excel ,
UserForm Code Showing Cell Protected Message
I have a spreadsheet set up to automate calculations and control data input for in process quality control checks. The spreadsheet is basically a series of input boxes requesting information from the user. To control the input of part numbers I have some code for a userform which populates listbox within the userform from another closed spreadsheet (opens & closes without updating screen) & enters the selected data from the listbox into a selected cell in the spreadsheet
all the input boxes and calculations are working well, the userform works well, BUT when I include the userform within the code I get the following problem, an error saying that I am trying to change data in a protected cell where data has been entered and then protected by the VB code, even though the code is not trying to change the cell.
I have tried just loading and unloading the userform and everything works well, it only fails when I actually use the userform, and then close it. from this I am fairly sure the problem lies within the form so I have been through the form code line by line and deleted anything that is not vital and the problem persists. Here is the form
Private Sub CommandButton1_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim Part As String
Part = ActiveSheet.Range("B1")
Msg = "Are you sure you want Part No" & vbNewLine & Part ' Define message.
Style = vbYesNo + vbDefaultButton2 ' Define buttons.
Title = "SELECT PART No." ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
Set_Data_1 ' Perform some action.................
Show UserForm From Another UserForm CommandButton
I have a userform button that when clicked loads another userform.
I am getting a Runtime Error 13: Type mismatch on the line in bold in the code below
Private Sub cmdAdd_Click()
Me.txtAdd.Value = Me.VarNo.Value
I do not get an error on the "Edit" button code which is similar so why is the above not working.
Private Sub CmdEdit_Click()
Me.txtEdit.Value = Me.VarNo.Value
Assign Userform Name To Variable For Use On Another Userform
In order to deal with the multitude of screen resolutions that can be found at our work, I have got a module to check the current screen resolution on loading the workbook. I then have set up 3 different sized userforms, all containing the same coding, and based on the displayed screen resolution one of these is open (the userforms are named Customer1, Customer2, Customer3).
The displayed userform then has a button to show another userform (Customer_Details), and this form requires some referencing back to the previous form for some of it's information eg,
customer_details.textbox1.text = customer(1, 2 or 3).textbox1.text
customerdetails.combobox1.list = customer(1, 2 or 3).combobox.list
way for me reference the specific "Customer" form that has been opened, without calling it by name?
Populate Userform Textbox From Another Userform
I want to populate a textbox (output) on one userform with data from a textbox (target) on another userform.
The data in the textbox (target) is the result of calculations in the userform code and is not gathered from or saved to a cell.
I want the textbox (output) to be populated at "Userform intialize" event.
I have tried various other methods without any success.
Close Userform Before 2nd Userform Loads
I have a large userform (Main) that the users enter data into. At the end of the data entry the users click OK and the data is transferred to a spreadsheet. I then ask the users if they want to add another record. If they click "Yes" all is OK. If they click "No" the userform should close and another "switchboard" type userform should open.
My problem is that try as I might I cannot get the (Main) userform to close. It only does so after the switchboard closes.
If I don't load the switchboard, main closes without issue.
I have left out the bulk of the data transferred to the "data" sheet in the code below.
Private Sub Main_OK_Button_Click()
Application.ScreenUpdating = False
Sheets("Data").Visible = True
Sheets("Data"). Range("F2").Value = Surname.Text
Dim result As VbMsgBoxResult
result = MsgBox("Do you wish to enter another record?", vbYesNo + vbInformation, "Continue...")
If result = vbNo Then
Show Userform Or Launch A Userform
I want to use the following to launch a userform I created.
Dim ans As Boolean
ans = msgbox("do you want to show the userform?", vbYesno)
If ans = vbYes Then
The trouble is that if I click yes, nothing happens.