I have a userfrom with a text box which is used to receive a telephone number from the user. The 'Event' code that checks the formatting of the telephone number is "tbCustTel_Exit". If my user enters a format other than what is acceptable for a tel number, they get an error message telling them to re-enter.
My problem is they still end up EXITING that text box they made a mistake in? How can I override them exiting the text box if they make a mistake - and keep them in the text box so they can try and re-enter the tel number again?
I need a cell to display a default value (something like "Input Here") which a user can overwrite with a value. When the value is erased, the cell should return to the default. Preferably, it'd be great if the cell reset to the default value whenever the workbook is opened as well (i.e. won't save the user's input value).
I have a userform with 10 textboxes which will all contain a time in HH:MM format. Could I have the userform to fill the textboxes with a default value once a time has been entered into textbox1. I would like the default value to be the time from the previous textbox plus 30 mins.
eg. So if I enter 14:00 into textbox1 I would like textbox2 to display 14:30, textbox3 to display 15:00.
If this is possible, could I add a Listbox with the options 1 to 10. Then would I be able to only uses the textboxes based on the number selected in the listbox. So if I selected 2 then just Textbox1 and Textbox2 would have values in them. For 8 being selected then Textboxes 1 through to 8 would be filled.
I am developing a form to get the user's name. I want to put some default text in the textbox where the user types their name. I want the form to delete the default text when the user clicks on the text box or after they start typing their name.
Attached is the form and code that runs the form : UserName.xlsm
I have a userform with numerous Textboxes and comboboxes for user input - however the end users aren't too PC savvy and I'm ending up capturing "Please Enter NameJohn Smith", "Please Enter Job TitleSales Manager" etc. My original Instructions told them to tab their way through the form, meaning each time they reached a TextBox their input would overwrite the ("Please Enter x") string prompting them for input.
Is there any way to replicate this "select all" on click (globally as there are potentially 50 to 100 textboxes and 12 varients of the form)?
Penfold Auto Merged Post;OK so I've made a little progress:
Private Sub UserForm_Click() TextBox1.SelStart = 0 TextBox1.SelLength = Len(TextBox1.Text) End Sub
The above selects all the text in a textbox - I think I need to apply this to the textbox "on click" - however that could be achieved? Then it needs to be generalised - ie:
1) Can a userform procedure be place in the midst a larger macro, so that it can get input from the user before running the rest of the macro? ie If the user leave the input field blank, the macro will exit will a msgbox.
2) I have a range(A1:A3) that i want my userform to display. This range is dynamic. The user will require to input the corresponding country next to it. how do i code the this? I will need to use a listboxes and textboxes right?
for example: userform shows city on the left, user will need to input the country on the right.
A1 - California (user input on the right) A2 - Shanghai (user input on the right) A3 - Mumbai (user input on the right)
I have a userform with 16 Textboxes Named "Text1" through "Text16". What I am trying to do is apply code that if there is content in the textbox it generates a new row after row15 and inputs the text in cellA of that row. Ex. "Text1" = JOE "Text2" = TONY......Hit Commandbutton1 on userform. It inserts Row16 puts "JOE" in A16.....then sequentially it inserts Row17 puts "TONY" in A17.
I want to force my user to input a date in a userform. I have a normal Textbox and assumed i'd be able to set the properties to mean that imput had to be an integer and the format had to be "00/00/00" but I can't see how to do this.
Code: Private Sub cmdSearchButton_Click() Dim txtbox As String 'stores lookup value Dim x As Variant 'value for wwid txt box Dim ForeName As String Dim SurName As String Dim wwid As Variant Dim iPosition As Integer
Here is my code, it does a vlookup and if the persons name is not found it will split the text entered into forename and surname but when i try and add
I have a question regarding frames and textboxes on a user form.
I have a user form that has a number of textboxes populated from the results two Comboboxes.
I decided to group some of the textboxes in frames for more logical viewing. I grouped the textboxes, moved them, placed two frame controls on the form then, finished by replacing the grouped textboxes. No code was altered or added.
When I ran the form, only the Comboboxes were functional and the text boxes were blank.
I am designing a from with a variable number of titles. The user should be able to insert a title into a column by typing in the title that he wants into a text box, and pressing a command button that I have created ( named add). The problem arises when I try to get the text to lie vertically as opposed to horizontally (in the cell, not as a text box. If this can only be done as a textbox, let me know). Is there any way to do this?
I want to add variable content to a textbox in a userform. I want to duplicate a Msgbox as closely as possible to allow me to position the box properly, and I would like a procedure to add a prompt to the userform as you would to a Msgbox. That is, I have found a solution using a cell in my spreadsheet, but I would like a fully vba oriented solution. In the message box you can say
MsgBox Prompt:="Put your message here."
For a textbox in a userform, I can link it to a cell (say A1) and then put data into the cell
I have a fixed height userform textbox that i would like to show the last line of. After there is text in the textbox, enable=false. I can see how to align for left, right and centre, but not for bottom.
I don't want to change the height or size of the textbox and just need to display the last line of data.
I have a calendar userform that enters a date into a userform textbox in the format mm/dd/yy.
I am in the UK, so default date format is dd/mm/yyyy but i need it as above - mm/dd/yy
So, when I get a MsgBox to repeat Textbox1.Value (the date from the calendar object, formatted mm/dd/yy) and repeat it in format dddd mmmm dd yyyy, it reads the value not as I want it, mm/dd/yy, but as the usual dd/mm/yyyy - so instead of reading 08/01/12 as Wednesday August 01 2012 it is giving me Sunday January 08 2012 - even though in the cells on the worksheet that are populated from the textbox, the date reads correctly, so 08/01/2012 is indeed 1st August 2012 not January 8th 2012...
So it's the MsgBOx function reading the textbox in the userform wrong, and formatting makes no difference...
Can I fix this without changing my regional settings? Is there a way to set the region in vba then unset when leaving the program? I don't want to have to change regional, and anyway, the program will be used by others who won't know / want to do that.
We can center horizontally with TextAlign (Left, right or center). Can we center text in a textbox on a userform vertically? I am working with multiple fonts, when a user selects a font I attempt to format a textbox as a display to show what is being created (Best WYSIWYG as I can). I have this particular font that is just ugly but is required. My textbox is set for a 12 point font but the displayed characters partially appear below the lower portion of the textbox. Think of cutting off about 1/3 of the bottom of all text in the textbox.
In my textbox it seems like the text could be moved up (some type of top margin?). All other fonts appear to display in the textbox vertically central, so I believe its the particular font selected causing the as displayed anomaly.
Is it possible to selectively format text in a textbox on a userform ie. to make some of the text bold, other parts underlined and other parts italic etc. The text which appears in my text box is entered automatically by a piece of code which extracts the contents of certain cells and arranges them in the text box as needed. I would now like to be able to display the text box with the text formatted so that its not just all in plain text.
I have a user form on which I need to create a textbox every time the user clicks a button. There are too many to create them all in advance and make them visible when needed. The sample attached, from this forum, is good, except, the numbers in the text box just scroll along and I need to see all the text typed into my textboxes. I would like the textboxes to be multiline, wordwrap and have them resize according to the amount of text.
I have a user form that has a combo box "City" two text boxes one called "Flight" and the other "Date". What I'm trying to do is to prevent the user from saving the data input from the user form if any of those three fields is left blank. The code that I have so far checks all of the required fields, if any are left blank a message notifys which field(s) is left blank and return the focus back to that field. But the rest of code also fires.
What I really need is either to stop the code if any fields are blank and return the focus back to the blank field, the user completes the field(s) and clicks the save again, or better yet, pause the code until all the required fields are completed and then complete the save. (There is actually another 200+ lines of code in this sub, but I deleted it to keep the post a little shorter.)
Is there a Macro to automatically print the selected print area (print area is also established within the macro itself) to a user's default printer; whatever that printer may be? Note that this printer and/or printer name could change depending on the user.
I would like this to actually select and print to the default printer without Excel having to ask you. I don't even want the "OK" box to show up if possible. I just want them to run the macro, execute all it's duties, and print, all in 1 shot.