I'm learning 'on-the-job' to code VBA macros and about a week ago I asked a colleague to test (UK/Australian) date entry into a textbox on a userform. I wanted to ensure users can enter virtually any acceptable date format. About 10 minutes after sending the colleague the workbook, she advised that inputting 29 February and a year that is not a leap year had the effect of showing the textbox date in reverse and transferring that date to the workbook with the year indicated as "29" eg. 06-Feb-29.
Since then, I've spent a good deal of time seeking a correction to the code. I've tried scripts for 'If IsLeapYear' with the 'MonthLength = 29' etc, various other if statements and shuffling the original date order of my code. The unadulterated code is below. Does anyone have an answer (other than an Error Handler with a msgBox, informing the user that the date format is wrong)?
Private Sub txtMonth_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim dDate As Date
dDate = DateSerial(Year(Calendar1), Month(Calendar1), Day(Calendar1))
dDate = txtMonth.Value
txtMonth = Format(dDate, "dd-mmm-yy")
On Error Goto EndMacro
MsgBox "The date format you've entered is not a valid format!"
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 few of my textboxes to not accept entries of greater than 40, Also need a message box warning to popup if this is done. I've seen some examples that are vaguely similar, but not quite what I need. I already have the following in place to limit characters:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) Select Case KeyAscii Case Asc("0") To Asc("9") Case Asc(".") If InStr(1, Me.TextBox1.Text, ".") > 0 Then KeyAscii = 0 End If Case Else KeyAscii = 0 End Select End Sub
I'm trying to create a spreadsheet that will add a value to one column from one specific cell. For example: I want to enter a name in cell G10 and add that entry value enters in A1, then erase that name and enter a name in G10 again and that entry value enters in A2, and so on and so forth.
I have a user form that has a combobox, two textboxes, and a button on it. When the form is loaded, the combobox fills with data from a worksheet I created. THe worksheet has a column with the item names, and another column with the quanity of each item. The combobox is filled with the item names. SO far I have this done. My issue is that when the user selects an item from the combobox, and enters a quantity in to the first textbox, and then clicks the button, I want the quantity in the textbox to add to the quantity cell that the part number from the combobox references to. Then I want this new quantity to show in the cell and the second textbox.
I have created a userform with a texbox and a "continue" button. In my macro I first ask the user to input name, date, etc then I have a line that says "frmDiscrepancies.Show". This code shows the userform but I am unable to type anything into the textbox. How do I activate the textbox so that I can type in it? Of course the next step is to be able to click on the command button "continue" and have it continue with the macro...
We need to have various users input data into a spreadsheet, so I have created a userform. Just need some code with the submit button to populate the central sheet, I think that I will need it to open the sheet, paste the data, save and close it.
This is my submit button as it stands, with the form and spreadsheet in the same workbook:
Private Sub btnSubmit_Click() Dim RowCount As Long Dim ctl As Control RowCount = Worksheets("Sheet1").Range("B1").CurrentRegion.Rows.Count With Worksheets("Sheet1").Range("B1") .Offset(RowCount, 0).Value = Me.coboPropSalutation.Value
I have a spreadsheet where for traceability purposes, I get some vba to enter elsewhere on the sheet, the date and time that data is entered into a cell. Is it possible to also somehow capture the name of the person entering the data. We are on a network, so the pc does "know" which user is logged in.
Textbox and SpinButtons, there is code for changing the date in a textbox by using a spinbutton. I have tried to use some variation of that for the purpose of changing time but to no avail. What my intention is, is that if someone enters 12:00 into TextBox that SpinButton_Up or SpinButton_Down can change the time to 12:01... or 11:59... respectively, and so on.
I have a user form with some option buttons (1,5,10,etc...) that are used so the user can select a given number of cells they want selected. My last option button is labled Other(optOther) and has a textbox next to it(txtOther).
What I am trying to do is give the user the option to either select one of the given numbers or be able to enter their own number. The data will then be extracted from one worksheet to another. I have all the coding for the optiong buttons with the given numbers, just cant figure the textbox one out.
My data starts on B5, so what i am trying to do is when the user enters number n, i would need data from B5:B(n+4).
If I enter into a textbox1 the following 09/31/2009 the result is that its not a date (because there is only 30 days in September - not 31). OR if I put in "13/25/2009" Can I have a macro that checks whether or not its a valid date and if so a message box appears that says: "Invalid date"
In my form I have the user enter in the current date in Textbox1. My program is designed only to work in 2009 so I want to check to make sure the 1) the date is in 2009 and 2) textbox1 is not empty. If it is empty then it displays a message box with "Not a Valid Date. Please Enter Date as MM/DD/YYYY. Date has to be in 2009" - this doesn't work. Second, if the date is outside of 2009 it is to display a meeage box saying "Date has to be in 2009".
Here is my current code which is not working.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) If TextBox1 = vbNullString Then Exit Sub
If IsDate(TextBox1) Then Else MsgBox "Not a Valid Date. Please Enter Date as MM/DD/YYYY. Date has to be in 2009" ...
I have a entry form in which i want to register customers. the first field is the customer number (which is unique(created by me) for every customer). This is TextBox 1 in the document. I would like to search for duplicates in worksheet 2, collumn A, when pressing "enter" to move from TextBox 1 to TextBox 2. A search for duplicates should start and a message should appear " duplicate found" if found, otherwise continue to TextBox 2 for further entry of information.
Please see my attached document for clarification.
Dim lCount As Long Dim rFoundCell As Range Dim sfind As String Dim cl As Range Set rFoundCell = Range("A1") For lCount = 1 To WorksheetFunction. CountIf(Columns(1), TextBox1.Value) Set rFoundCell = Columns(1). Find(What:=TextBox1.Value, After:=rFoundCell, _ LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False) With rFoundCell End With Next lCount.........................
this macro looks up in column A (a list of names) the name entered in textbox1 (of userform2). if found - the value is "copied" to E13. (if not - showes message - " does not exist") for example: it found the value "Dainna" (which was typied in textbox1) and copied it to E13. i want the macro to keep on to the next cell (in the row where Dainna's in- B3) and copy the age to F14.
Is there a way of a user can add a number in a cell and this would hide a different amount of columns.
Ideally I would prefer a drop down with dates and the user could select a forward date and all the columns with dates up to that would appear. This would mean they could look as far our as required and all unwanted data would be hidden.
Basically at the moment our static data group use a generic sheet which lists all possible field variables. However, what I want to do is design something which only shows the fields that need to be filled out (ie if the field is shown it needs to be input).
Once the form is filled out it will get saved and sent via email, where it is then printed out and input by our data group. One way I thought about approaching this was to have 18 sheets which are hidden, and which are then selected when a report type is filled out. The other way would be to have IF statements but I think that would get complicated on the one sheet. Just really looking at ideas at this stage.... For example there are 30 fields on the sheet that we use now, but some reports may only need 5 of these fields - I therefore need to "hide" the remaining 25...
I have the following code that enters data from a user form, the problem is that the textbox (Locker) data will not validate when entered into worksheet.
Private Sub cmdEdit_Click() Dim rownum As Integer rownum = 2 'Prompt user with message box asking for input in both text boxes If Me.txtNumber = vbNullString Then response = MsgBox("Please enter a Work Number", vbInformation) Me.txtNumber.SetFocus Else ' Insert the work no., driver, locker, keys issued & keys On hand ActiveCell = Me.txtNumber.Value ActiveCell. Offset(0, 1) = Me.txtLocker.Value ActiveCell.Offset(0, 2) = Me.txtIssued.Value ActiveCell.Offset(0, 3) = Me.txtOnHand.Value................
I need of a formula that will look through a list of text strings, spread out through two columns) and compare each one to a user defined entry. When it finds a match against this entry I would then need it to compare another set of text strings on the same row as the entry that it previously matched against.
If it was to find a match on only the original text string it would need to return a true result and if it matched on the original text string and also one of the other text strings on the same rowit would need to return a false result.
I currently have a formula to compare all text strings against the user defined entry and if it is contained in the first 2 columns it returns a true result and if it is contained in both ranges of text strings it returns a false result but i need it to apply the rules per row.
Below is the formula that I am currently using if this helps as a starting point. If you need a subset of the data I can supply this.
=IF(SUM(IF('HBO Frequency Projections.xls'!NOT_HOMEBASED"",IF(ISNUMBER(SEARCH('HBO Frequency Projections.xls'!NOT_HOMEBASED,C5)),1)))>0,"NOT HBO",IF(SUM(IF('HBO Frequency Projections.xls'!HOMEBASED"",IF(ISNUMBER(SEARCH('HBO Frequency Projections.xls'!HOMEBASED,C5)),1)))>0,"HBO","NOT HBO"))
I have searched the forum but can't find an answer to my problem. I have a list of about 3000 streets, a sample of which follows:
ARBROATH ST ARCOLA ST ARGO PL ARIES PL ARMSTRONG AVE ARTHUR AVE ARVIN CT ASHGROVE CR ASHLEY GROVE CT ASHWORTH AVE...................
I know how to populate a List Box, but rather than having to scroll through the entire lot I would like to just have to type in a few letters and the output only display streets that start with only those letters. For example, if I type in AS only the following appear in the listbox.
ASHGROVE CR ASHLEY GROVE CT ASHWORTH AVE........................
I have a row of dates in row 2 (all sequential, from Nov through to June next year)
I have a row of number entries in row 3 (to correspond with the date in row 2 it was entered on).
I want to be able to add a new entry (a number) into a text box, click a macro button, which makes the text box input be moved into the cell underneath todays date (so every day the cell will move one column along)
I've managed to make myself a textbox, and a macro button, but I'm stuck with how to make it all work.
I have created a simple userform that is linked to a button on sheet1. When the data in the userform is submitted, I set it up so it goes into a database under sheet2. The problem is, I don't want anyone modifying the entries in the database. Usually I would protect the sheet with a password, but when I do that, there is an error when the userform is submitted. The only thing I can think of is to hide sheet2, which doesn't seem like a great solution.
Is there any way to protect my database from being modified yet still allow the userform to be linked to it?
I need to save the data of For Eg. A form in Sheet 1, B form in Sheet 2, C form data entry in sheet 3.
what is happening now is that, all the entries are going in the Active Sheet that is open in the excel file. I want to automate the process of data entry, by making it enter data from specific form in specific sheet.
I have a table that i use for a customer database. and the end user adds new customers to this table, what i would like is for a message box to pop up whenever cell B2 matches an entry in a column in the customers table. the table starts on row 25, and the column i would like to check for duplicates is column B. I would like the message box to give the user the message "A customer by this name already exists, Would you like to load this customers file?" If the answer is yes, then the row that the match was found on would be copied and pasted onto row 1. if the answer is no, then nothing else happens. I hope this makes sense, i am posting this sheet of my workbook for reference.
I have a worksheet in which i am asking a user to enter manually a number in cell E3. Suppose the user starts with 100, then the next time he is entering in E3 he shoudnt be able to enter 100 nor any number less than 100. I dont have a range for the numbers that the user is going to enter.Therefore countif function does not work. Is there any way that i an store the number taht the user enters first in cell E3 and then use that database to avoid the user from entering the same or a number lesser than that number.????