I have a macro that creates a new sheet, the name of which is based off of an input box. Does someone have some generic code to ensure that the user inputs a valid name? Here's what I have, it only checks to see if the name is a duplicate:
'Prompt user for the name of the output sheet newsheetname = inputbox("Name Your Output Sheet:", "Notice!", "Margin Output")
'Check whether or not the name is taken TestName: For a = 1 To Sheets.Count If Sheets(a).Name = newsheetname Then newsheetname = inputbox("Name Taken. Please Rename Your Output Sheet:", "Notice!", "Margin Output") GoTo TestName End If Next a
It's the last road-block left to making this function work. The Problem is in the If...Then statement. If A is true the formula works, but is it is not, then it returns a value. The Expression
IBGLink = (E & CustomDate & EndOfLink) works on its own, so there is an issue with If Application.WorksheetFunction.IsError(A) Then Does anyone know an alternative way of validating a variable or a trick of sort that can be used here. A to E and CustoDate and CustDatePN are declared as global variables.
Function IBGLink(IBG_URL As String, FrstDate As Date, ScndDate As Date, Optional EndOfLink As String) A = Mid(IBG_URL, Application.WorksheetFunction.Find("/200", IBG_URL), 8) B = Left(IBG_URL, Application.WorksheetFunction.Find("/200", IBG_URL)) C = Right(IBG_URL, Len(IBG_URL) - (Len(A) + Len(B))) D = Left(C, Application.WorksheetFunction.Find(".200", C)) E = Left(IBG_URL, Application.WorksheetFunction.Find(".200", IBG_URL)) CustomDate = Format(FrstDate, "yyyymmdd") CustDatePN = Format(ScndDate, "yyyymmdd") If Application.WorksheetFunction.IsError(A) Then IBGLink = (E & CustomDate & EndOfLink) Else: IBGLink = (B & CustomDate & D & CustDatePN & EndOfLink) End If ................
i am trying to make a user form with two msg boxes (To and From Date). In excel spreadsheet It was rather easy to bring a popup msg if they were invalid under some stated rules. see below a rationale of the rules where A3=From Date and B3 To Date and the desired outcome of is:
[Code] .......
So i wonder if it is possible to make a VBA code to validate these two dates? and bring a warning msg after keypress or after pressing submitcmd or any other available if available.
I'm attempting to require a numerical entry in a cell using data validation. The function =AND(ISNUMBER(cell),NOT(ISBLANK(cell))) does not perform as intended. Unchecking "Ignore Blank" has no effect. The ISNUMBER function evaluates to TRUE on a blank cell. When used outside of data validation, NOT(ISBLANK(cell)) evaluates to FALSE on a blank cell, making me think the AND(...) function should be sufficient.
I have a truth table, let's say it is an ordinary 2^3
ID 1234567 8 condition AYYYYNNNN condition BYYNNYYNN condition CYNYNYNYN
Currently I am pasting the results of a DB query into the left half of my sheet and I analyse this data using Excel functions in the right half. Among these functions are cells that evaluate the conditions above, e.g.: cond A is evaluated as true or false in column H cond B is evaluated as true or false in column K cond C is evaluated as true or false in column M
What I would like is a function to place at the end of the row (col T) which will display the ID of the relevant column in the truth table that the three values together correspond to, e.g.: A=T, B=T, C=F gives result 2 A=F, B=F, C=T gives result 7
I have been trying to achieve the following with formulas but have not been successful. I am making a simple schedule, and I am trying to validate the cells so that you can not schedule someone for multiple tasks during the same time range. In the example that I attached, Harry is diswashing from 1:00 - 4:00 but is also scheduled to paint from 2:00 - 5:00 (this should not be allowed). How can I achieve this with code?
I'd like to create a data validation with 1 dropdown list in the second worksheet in B4, relating to 3 cell ranges on the first worksheet (COS, Expenses & Capital). If 3 can't work, I've created 1 called 'dropdown' which incorporates all 3.
which formula I need to write into the validation, or what else I need to do in order to find a solution to this.
I have two userforms. When the user chooses the choice "Other" in the userform frmTradeSickOther, another userform called frmOther will be called. At this point, the user will enter some required comments in a textbox (called txtOther) and click the "Add Comment" button. If the user does not enter anything, a prompt will inform the user to type something in the textbox.
My problems: Once the user clicks okay to the prompt, frmOther is called back. When it's called back, I want the cursor to blink in the textbox. Eventhough I have SetFocus on the textbox, it does not work. I don't know why.How do I prevent the user from just hitting enter (i.e., accepting blank lines as comments) and bypassing the commenting part. The code below accounts for hitting enter once (i.e., one blank line), but not multiple times. How do I do this?
Here is what I have when the user clicks on the "Other" choice in frmTradeSickOther:
Code: Private Sub optOther_Click() Unload Me frmOther.Show frmOther.txtOther.SetFocus 'This gets the cursor to blink in textOther when frmOther is called. End Sub
Here is what I have when the user clicks the "Add Comment" button on frmOther:
Code: Private Sub btnAddComment_Click() On Error Resume Next txtOther.Value = Trim(txtOther.Value) 'This is to make sure spaces aren't accepted as a comment. If Me.txtOther = vbNullString Then Me.Hide MsgBox "Please enter the necessary information.", vbInformation, "Required Field" Me.Show Me.txtOther.SetFocus 'Here is where I set focus on txtOther. Exit Sub End If
'Everything below is to add comments automatically to each cell when a value is changed.
Application.CommandBars("Cell").Controls("Delete Comment").Enabled = True If Not ActiveCell.Comment Is Nothing Then Application.CommandBars("Cell").Controls("Edit Comment").Enabled = True Range(curCell).ClearComments
I want to inform my users via a message box if they have not entered the previous month's information. The months are populated via a User form using a combo box selection. The months start from April through to March and are entered into the worksheet range ("aa3").
Data is entered monthly by the team. I don't know how to begin with this. I've managed to inform them when they've already entered that months information, but I don't know where to begin with this.
while trying to limit the user's input to a userform textbox to no avail. For example one textbox on the form should only be numbers and I therefore want to restrict the user to typing in a two digit code like 02 or 72 (not for calculations). Another textbox I only want to allow the user to input 6 characters in the format letter, four numbers and a letter. If the user inputs the wrong stuff a message box pops up and the focus is reset
I am trying to create a form with dropdowns (see attached file), so that when a particular company is selected in the first drop down, the second and third only display the relevant business units and departments respectively.
The INDIRECT function has confused me and I am not sure how to use it.
I am trying to wrap my brain around dependant dropdowns and have hit a brick wall.
Using the Contextures web site [url="http://www.contextures.com/xlDataVal02.html#TwoWord"] I can get part of the problem to work but when I try to add a third dropdown i get lost. Attached is a sample of the workbook.
I'm building a form comprising some text boxes and drop down lists. I'd like for data (once input into the form by the user) to input, upon click of a submit button, into an excel spreadsheet, row by row.
Here's where i'm struggling: I need the form to validate data before submitting. Namley, the form must not allow null values to be submitted and will show a message box telling the user what is needed.
Below is what i've got so far. I've tried playing around with this but am struggling to implement the above functionality:
I have been using excel form last 1 year. I do have good knowledge for macro but for validating emailID entry I am not getting success.,So if any body can give me a sample code for validating email ID entry or a macro for checking and highlight those email ID which r wrongly formated..
I'm currently developing a calendar that has a list in it with lets say 4 options. What I want the calendar to do is calculate at a specific 'cell' the number of entries that are selected during the month.
The idea is to have a drop down on each 'day' and a counter that calculates the number of times one specific options has been selected. Once the option has been selected the 'day' will change to the corresponding color.
I have generated a matrix in excel through iteration (I'm trying to calculate a dinamic covariance matrix between 50 values) which looks like this:.......
A 50x50 matrix. What I have generated in each cell is not the formula, but the text of the formula. Somehow Excel has a valid formula in a specific cell, but "doesn't know yet" that within the cell there is no longer a text. So, to make every formula run, I have to go cell by cell pressing F2, then enter, 2.500 times. Notice that in each formula I don't have something like this:
+"+COVAR(Rends!C4:AB4;Rends!C4:AB4)" or '+COVAR(Rends!C4:AB4;Rends!C4:AB4)
but the valid formula: +COVAR(Rends!C4:AB4;Rends!C4:AB4)
I am trying to find out how many projects might be active as of a certain date.
I have a tab in excel that contains project data. For each project there is a "Start Date" and there might be an "End Date"
My question is, how do I count all the rows where the start date is Less than a given date and the end date is after a given date? The wrinkle is... if the end date is empty then obviously it should be counted as well (assuming the start date is still before the given date).
textbox1 containing the province textbox2 containing the city
If didn't click any value of province the city textbox2 don't have any value and if i click the one of the province the city will now have a value . Is that possible
I'm not a novice but this might be something simple I didn't realize. I am creating a quoting sheet for a steel fab company. I have created dopdowns for the different materials and sizes but the dropdown is way too big. I need to have a column that helps me filter the dropdown more so I don't have to scroll through litterally hundreds of steels to find the one I need. The good news is that most steels have prefixes that make them easier to filter.
For example:
L-3x3x1/2 L-2x2-1/2x1/4
C6@8.2# C8@11.5#
W12@16.0# W21@44.0#
What I'm looking for is a way to have a dropdown that has all of the prefixes (L, C, MC, W, PL, etc) in it and when I select one of them the next column (the actual description of the steel as shown above) will only give me the specific steels for that steel shape (L,C,W,etc)
Currently I'm putting one row of say the MC shapes and one row of the C shapes and one row of the L shapes then copying them as needed. It's a lot of work and you can easily make a mistake.
I have two dropdowns, both use a different source lists and both use the same reference cell to deliver the result, My problem is I need the contents of the cell to be deleted and the new result inserted. At the moment if the cell is already filled the new result is put in the next column.
What I would like to happen is to have two dropdowns one above the other (B2 and B4) and the result in a cell below them in B6, which ever dropdown is used the result will fill the cell B6 this cell is then used for vlookup.
Biz develop an xls tab that will have dropdowns. Essentially, one dropdown will filter another dropdown... etc... Would also want a DISTINCT list for all dropdowns...
I've used the DropDown's from the CONTROL toolbar and although it seems easy enough to supply a datasource, not sure how filter/distinct might work.
I have a project that has a variable number of worksheets, dependant on the number of models in the job. These worksheets usually only use a single page, but may use two pages if the model is large (not often the case though). I have a "Template1" worksheet that is copied as a whole, to equal the number of models.
To minimize the file size that is generated when copying out the "Template1" worksheet, I have put the template of the second page on a separate worksheet "Template2". Now the initial copy is only of a single page, and the second page is only copied into the new worksheet if needed.
Sub AddPg2() Dim CrntPg As String CrntPg = ThisWorkbook.ActiveSheet. Name Application. ScreenUpdating = False ThisWorkbook.Worksheets("Template2").Visible = True Worksheets("Template2").Activate ActiveSheet.Range("A47:T96").Select Selection.Copy Worksheets(CrntPg).Activate ActiveSheet.Range("A47").Select ActiveSheet.Paste ActiveSheet.Range("D58").Select ThisWorkbook.Worksheets("Template2").Visible = False Application.ScreenUpdating = True End Sub
If I do this process manually, I toggle DesignMode "on", and it works, but I if I record the process, toggling DesignMode does not show in the code. how to include the comboboxes and checkboxes in the copy/paste process.