Age Validation Procedure Not Working

Jul 9, 2012

The code below is fired from a Worksheet Change Event on cell c18. The cell has a userform calendar control to select Date of Birth. What I want the code to do is check the age at the current date and if it is below 16 or over 25, then show the appropriate message. I cannot use data validation to not allow values outside this age range because there will be instances where a person's details can be added if their age is under 16 or over 25. I just need to alert the inputter in case they are unaware or have inputted incorrectly.

When the message box pops up, if they click Yes then the code should take them to the next cell for inputting. If they click No then it should stay in cell C18 and hopefully pop the calendar back up (I've not tested this bit yet).

The code as it stands brings up the "This person is under 16 years...." message no matter what date of birth is input.

VB:
Sub AgeValidation()
Dim age As Integer
Dim dob As Range
Dim AgeMsgAnswer16 As String
Dim AgeMsgAnswer25 As String

Set dob = Worksheets("Monitoring Form").Range("c18")

[Code] ....

View 3 Replies


ADVERTISEMENT

Secondary List Validation Not Working?

May 13, 2014

I have a log that I have data validations on.

Column C validates on a list called "Division"
Column D is supposed to validate based on the selection in Column C, and give the list based on Column C.

I had it working awhile ago, then I went and changed the lists. Now, the lists are not validating appropriately (I'm not getting the expected drop down in D based on the selected in C) and I don't know why its not working anymore.

View 1 Replies View Related

Data Validation Not Working At Start Up?

Apr 13, 2011

For some reason my data validation cell is not working when I first open up the spreadsheet.

I have to go to data validation, open it and just hit ok, then I am able to use my drop down list.

My data is this
"=OFFSET(name,MATCH(LEFT(B2,LEN(B2)),LEFT(address,LEN(B2)),0),0,SUMPRODUCT(--(LEFT(address,LEN(B2))=B2)),1)"

View 5 Replies View Related

Data Validation Not Working At Start Up

Mar 28, 2013

I have a data validation list does nothing upon start up (not working). The formula is:

=OFFSET(E$1:E$5,MATCH(C94,LEFT($B$3:$B$87,LEN(C94)),0)+2,0)

If I go into data validation and just click OK (leave formula as is), it starts working again, but the next time I start up the same thing happens.

View 3 Replies View Related

Date And Data Validation Not Working?

Jun 12, 2014

I'm trying to add code to validate the format in which users are entering in a date within my userform, and I am also trying to validate if they enter in a specific value within a combobox, they will be unable to enter data within a textbox further down in the userform. Here is how my code is currently written, but neither my date or data validations are working. I have bolded the new coding I added to an existing code that was created by someone else at my job prior to it being given to me.

[code]
Private Sub cmdAdd_Click()
Dim lRow As Long
Dim lPart As Long

[Code].....

View 14 Replies View Related

ListBox Validation On UserForm Not Working?

Jan 22, 2014

I have a UserForm with Combo Boxes, List Boxes, Text Boxes etc. When the OK button is clicked I want it to ensure certain fields are not left blank and notify the user (see code below). This works great for the combo boxes but not for list boxes. It seems to skip over that code. In other words, in the code below, if a manager is not selected, it doesn't notify the user.

Private Sub OkButton_Click()
'Verify fields are not left blank
If cboAgent.Value = "" Then

[Code]....

View 2 Replies View Related

Validation In-cell Drop-down Not Working

Apr 22, 2003

I have set cell validation to use a named list and checked 'In-cell drop-down'. The validation works but the drop-down is not working.

View 9 Replies View Related

Cell Validation Code (If Then Else) Not Working As Required

Jul 10, 2012

I have the following code to check the date of birth entered into cell C18 and to alert the inputter if the age is either under 16 or over 25.

VB:
Sub AgeValidation()
Dim age As Integer
Dim dob As Range
Dim AgeMsgAnswer16 As String
Dim AgeMsgAnswer25 As String

[Code] .....

It works to some extent in that the correct message box pops up if the age is under 16 and similarly if over 25. If answering Yes on either message box then the correct thing happens. Its what happens if the inputter selects No thats not right. If the age is under 16 and the user selects No in answer to "Is this correct?" then the code is clearing the cell contents and showing the calendar again but is also popping up the 'Over 25' validation message box which then won't go away until Yes is selected. Also there are then multiple copies of the calendar open.

What I need the code to do is look at the date selected from a popup calendar in c18 and decide if that age is within the 16-25 year old range. If it is outside that then the inputter needs to be alerted to it. I can't use the inbuilt data validation because there are some scenarios where it would be acceptable to have an age outside of that range but we want to cover inputting errors as well as double checking the age.

When a msgbox pops up to alert the inputter and they choose "Yes" to say the date of birth is correct then I want the focus to go to cell C20 ready to input the next piece of information.

When the inputter selects "No" on the message box, then I want the original date to be deleted and the calendar to reappear so they can select another date. So effectively resetting the field so they can start again choosing a date like when they first entered the cell.

View 4 Replies View Related

Function Not Working In Data Validation List

Jul 23, 2014

I need to compare 2 cell with 1 specification reference.But the function can't give return value as per required.Both 2 input cells using Data Validation List.

Please refer attachment for some examples : matching.xlsx‎

View 2 Replies View Related

Validation And Lookup Function Are Working Weird

Sep 2, 2009

There is a range of quarters and relevant dates like from and till - means if you have 1 Q 2009 => it means from 01.01.09 till 31.03.09. I would like to have following in my excel. There is a validation for selecting Q from list, once you select Q, there is LOOKUP function displaying from and till dates. But however it's not working, in same cases it's working, but in most cases the from/till period is not relevant to selected quarter.

View 2 Replies View Related

Data Validation - Blank Cell Not Working

Sep 11, 2013

I have a tracking sheet... in that I got in column C say "priority" there I have a drop down list date say P1, P2, P3

Now I need to restrict that if a user enters a data in the C2 and trying to enter a data in D2 leaving the drop down list data blank in C2. A error message saying "pls select priority forst" etc...

I got the following solution from moderator:

You can apply the Custom Data Validation formula =LEN(C2)>0 to D2, making sure that Ignore Blank is unchecked.

It works but, when I enter something in that cell it gives the error message and when I click OK or Cancel it just ignore the conditions and leave the data what ever I entered and moves further.

View 1 Replies View Related

Ensure Value Entered Into Textbox - Validation Not Working Properly

Jul 1, 2014

I'm using the following code to try to ensure a value is entered into a text box, but when I click over to the next text box skipping the first one entirely, I don't receive any message indicating the previous box is empty. I'm trying to make it so certain fields are required and others are optional. Here's the code I'm currently using:

[Code] .....

View 14 Replies View Related

OFFSET / Data Validation - Dropdown List Not Working

Aug 21, 2012

I have the following function in cell (table 2 column C) where I want to find a contact name from my table TMI if 3 criteria are true (client, account, NAM) For each contact I have 1 true combination of client/account/NAM but for each client/account/Nam I can have several contacts.

{=OFFSET(TMI[[#Headers],[Contact]],MATCH(1,(TMI[Client]=$B$1)*(TMI[NAM]=C3)*(TMI[Account]=B3),0),,COUNTIFS(TMI[Client],$B$1,TMI[Account],B3,TMI[NAM],C3),1)}

The function is working well but shows only the first contact name if I have 3 contacts for the same client/account/NAM. (I pressed Ctrl+Shift+Enter)

When I press F9 on the function, it shows all the contact names! so they are somewhere.

Hence, I have copied and pasted this function into data validation / list in the source but it came up with an erreur.

Table TMI:

A B C DClient
Account
NAM
Contact
Comments

[Code]..

Table with offset function:

A B C D

Chi
Account
NAM
Contact name
Comments

[Code]..

All client, NAM and account lists are dynamic !

View 2 Replies View Related

Excel 2007 :: Validation With ISTEXT Not Working When Number In Cell?

Dec 3, 2012

I'm trying to validate a cell in Excel 2007 that should contain only two letters.

Formula:
Code:
=IF(AND(LEN(A1)=2,ISTEXT(A1)),TRUE,FALSE)
When the value of A1 is JK, the result is TRUE
When the value of A1 is 12, the result is FALSE

When the value of A1 is 3K, the result is TRUE
When the value of A1 is K3, the result is TRUE

When the value of A1 is 123, the result is FALSE
When the value of A1 is JKL, the result is FALSE

When the value of A1 is 3, the result is FALSE
When the value of A1 is K, the result is FALSE

The LEN function works as expected, but the ISTEXT function does not, whenever the cell contains a number and a letter. I've tested the LEN and ISTEXT functions separately, and get the same results.

Is it me, or is it Excel?

View 7 Replies View Related

Macros That Were Working In Excel 2003 Are Not Working In 2007

Jan 25, 2010

I have a workbook in excel 2003 which I had been running the following macros (listed below). We recently upgraded to Excel 07, and neither are working. When I try to run them, the "debug" option highlights the following line in the sort macro "Range("A2:z" & lastcell).Sort key1:=.Columns(1)". This is driving me crazy, as the macros worked perfectly under the older version of Microsoft. Is there an issue with crossfunctionality between '03 and '07'.

Private Sub Worksheet_change(ByVal target As Excel.Range)
If target.Column = 1 Then
ThisRow = target.Row
startRow = 1
i = 1
Set ws = ActiveSheet
maxRow = Cells.SpecialCells(xlLastCell).Row
maxCol = Cells.SpecialCells(xlLastCell).Column
ActiveSheet.UsedRange.Interior.ColorIndex = xlNone
Do While i

View 9 Replies View Related

How To Set Outside Procedure

Apr 21, 2009

I have the following codes used with a user form, but they are all not working due to an outside procedure problem,

View 14 Replies View Related

Event Procedure

Dec 11, 2007

I've created a macro with a custom dialog box, but I don't know how to make the transition from when I make the dialog box pop up, the user enters the information, then they click "Continue" or "Cancel" or whatever it may be, how to do I make it happen from there out?

Do I make the command buttons a boolean and if they click it's true? How do I make it work?

View 14 Replies View Related

If Formula Or VBA Procedure

Sep 6, 2007

I need in column E the value "complete" but only against the last row of each system from column B, if column D ="draft del" and is not null. For example system V0523 is draft del and so is complete, therefore I would like "complete" in column E row 10.

******** ******************** ************************************************************************>Microsoft Excel - CA_ TDM_ ACQD_TBLDATAMODULE(LEFT JOIN)_all_systems.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutB2B3B4B5B6B7B8B9B10B11B12B13B14B15B16B17=
ABCDE1EIACODXA*LSACONXBDM_MGT_STATUSDM_QA_STATUS12EH101-VH71V00V00**3EH101-VH71V00V00**4EH101-VH71V00V00**5EH101-VH71V01V01WIP*6EH101-VH71V01V01WIP*7EH101-VH71V01V01WIP*8EH101-VH71V0523V0523001DRAFT*DEL*9EH101-VH71V0523V0523001DRAFT*DEL*10EH101-VH71V0523V0523001DRAFT*DEL*11EH101-VH71V0552V0552001**12EH101-VH71V0552V0552003**13EH101-VH71V0552V0552005**14EH101-VH71V0552V0552007**15EH101-VH71V0552V0552009**16EH101-VH71V0552V0552011**17EH101-VH71V0552V0552013**CA, TDM, ACQD_TBLDATAMODULE(LEF*
[HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

View 9 Replies View Related

Run VBA Macro From Another Procedure

Sep 2, 2009

I have the following macros,but want them to run in sequence but i don't know how.
I plus won't another macro to save the archive as .txt

1. I use the following macro to open .txts so the cells go where i want to

Sub NewTextImport()
myfile = Application. GetOpenFilename("Text Files,*.txt")
Workbooks.OpenText Filename:=myfile _
, Origin:=1253, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:= Array( _
Array(0, 2), Array(17, 2), Array(34, 2), Array(56, 2), Array(102, 1)), _
TrailingMinusNumbers:=True
Columns("A:A").EntireColumn.AutoFit
Columns("B:B").EntireColumn.AutoFit
Columns("C:C").EntireColumn.AutoFit
Columns("D:D").EntireColumn.AutoFit
End Sub

2.Remove the unwanted zeros from Column E.............

View 2 Replies View Related

Running A Procedure

Jun 19, 2007

I have written a macro in Excel VBA. The code is divided into modules and each module is having various procedures. I'm trying to run a procedure written in modules2 from module1. I'm getting an error message "Expected Variable or Procedure, not module".

View 2 Replies View Related

Call Procedure From Add-in

Nov 27, 2007

I have a userform in an add-in (which is loaded), when I try and call it from an excel sheet, I get the following error "Variable not defined"

Private Sub CommandButton3_Click()

UserForm1.Show

End Sub

The code in the userform is all private subs.

Similarly when calling a public sub from the add-in such as;

Private Sub CommandButton3_Click()

Call SillySub

End Sub

I get the error "Sub or Function not defined".

How should I be doing this?

View 3 Replies View Related

Call A Sub Procedure From Another

Jun 19, 2008

how do you call another sub's function from another sub? For example:

Sub Worksheet_SelectionChange(ByVal Target As Range)

StartingDate:
Static STempHolding As String
If STempHolding <> "" Then OldStartingDate = STempHolding
STempHolding = Target.Value

EndingDate:
Static ETempHolding As String
If ETempHolding <> "" Then OldEndingDate = ETempHolding
ETempHolding = Target.Value

End Sub

If i just wanted to call the StartingDate function, from my Worksheet_Change sub how would i do that?

View 5 Replies View Related

Run Macro / Procedure In Another Workbook?

Feb 28, 2006

When i open the MS-excell and i go to see the VBeditor i can see the following in the project window:

- spacereport(space.xla)
-microsoft excel objects
sheet1

[Code].....

All the code in spacereport project, let me go to File-->Space and then run a report previously added. what i would like to do is, being in the book3 project, execute modules and forms from spacereport project.

View 6 Replies View Related

Prevent Screen Changes During Procedure

Apr 26, 2014

I have 2 workbooks open. In the workbook that I am working in I run a macro from a userform to copy a worksheet from the other workbook that is idle in the back ground. I also display another user form that says "please wait" while the macro is running.

The problem I have is even though screen updating is set to false the screen switches over to the other workbook while it is copying the desired sheet and switches back to the workbook I am copying to after the macro completes. Also the "Please Wait" userform disappears while the other workbook is displayed and reappears when the initial workbook returns.

Below is my code which works without issue but perhaps there's a better way to copy between workbooks that would prevent the screen changes?

[Code] ........

View 3 Replies View Related

Macro - Procedure Too Large

Oct 15, 2008

I am using following event macro and it repeats itself more than 300 times. I am at a stage where I am getting a message "Compile Error, Procedure too large", I tried to break it into two but that's not working.

Option Explicit
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cl As Range
Dim lng As Long
Application.EnableEvents = False

Select Case Target.Address
Case "$E$3"
If Target.Value = "Yes" Then
SelectNumber:
lng = Application.InputBox("Please enter number 0 to 100", , , , , , , 1)
If IsNumeric(lng) = False Or lng < 0 Or lng > 100 Then GoTo SelectNumber
Range("G3") = lng
Else: Range("G3") = 0

.................................................(above statements repeat more than 300 times for different cells)..............................
Application.EnableEvents = True
End Sub

View 15 Replies View Related

Number 3.5 Is Getting Rounded To 4 In Procedure

Apr 17, 2009

If you run it type in 3.5. What gets returned from the procedure is the number 4 NOT 3.5. I think its related to the data type declaration but i thought a data type of long would include the number 3.5.

View 5 Replies View Related

Calling A Function In A Procedure

Feb 2, 2010

I need to extract the filename “My Excel File” from Worksheets(“Sheet1”).Range(“A1”), whose value = C:Documents and Settingsuser1DesktopMy Excel File

I found on Chip Pearson’s site a Function TrimToChar which, using SearchFromRight and a TrimChar of “” will trim OFF the filename “My Excel File”, leaving the Path.
But, I think I could use his function to tell me the number of characters in the Path and then use that to extract the remaining characters from the total character length (Mid Function)

Problem is, I don’t have a clue how to call a Function in VBA to work on Worksheets(“Sheet1”).Range(“A1”). How do you set the InputText , TrimChar, & SearchFromRight?????

(eventually, this will be in a loop, where I extract the filename from a Dynamic Named Range (list) in Column A)

View 3 Replies View Related

How To Call A Procedure / Function

Mar 2, 2012

I have found some code that does what I want- but i do not understand how to use - call it. The programmer says ...

GetNetworkIPAddress()
' can be called from a worksheet cell using the formula:
' =GetNetworkIPAddress()

I have put this in a cell but i ger an error #Name?

what should i do ?

View 9 Replies View Related

Display Running Procedure Name

Jun 27, 2012

I have a worksheet with 15 procedures running after each other and repeated about 50 times. How can I display to the user which procedure is running at the moment. I'm using a form with a label on at the moment, but it doesn't update after the first display.

View 1 Replies View Related

Procedure To Send Group SMS

Aug 26, 2012

I'm working on a management program for a small company. As one of it's feature i need a procedure which send a prewritten SMS to it's employees using a web service like fullonsms.com (10 employees at a time.).

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved