Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Validation - Precede with LR and between 6 and 9 characters long.

Hi,

I currently have a validation rule running whereby it will only allow a code
that starts with LR and is 6 character long i.e.

LR8976

I need it to allow for either 6 or 9, or allow for between 6 and 9.
Preferably one or the other as it leaves less room for error.

Can you help?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,388
Default Validation - Precede with LR and between 6 and 9 characters long.

Hi,
If you post your current data validation formula, we could probably help you
modify it.
Regards - Dave.

"forevertrying" wrote:

Hi,

I currently have a validation rule running whereby it will only allow a code
that starts with LR and is 6 character long i.e.

LR8976

I need it to allow for either 6 or 9, or allow for between 6 and 9.
Preferably one or the other as it leaves less room for error.

Can you help?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Validation - Precede with LR and between 6 and 9 characters long.

On May 7, 10:12 pm, forevertrying
wrote:
Hi,

I currently have a validation rule running whereby it will only allow a code
that starts with LR and is 6 character long i.e.

LR8976

I need it to allow for either 6 or 9, or allow for between 6 and 9.
Preferably one or the other as it leaves less room for error.

Can you help?


Maybe...

for either 6 or 9

=AND(CODE(A1)=76,CODE(MID(A1,2,1))=82,OR(LEN(A1)=6 ,LEN(A1)=9))

or, for between 6 and 9

=AND(CODE(A1)=76,CODE(MID(A1,2,1))=82,LEN(A1)=6,L EN(A1)<=9)

assuming entry into A1.

Ken Johnson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Validation - Precede with LR and between 6 and 9 characters lo

Hi Ken,

Will this notice whether or not there is an "LR" at the beginning?

"Ken Johnson" wrote:

On May 7, 10:12 pm, forevertrying
wrote:
Hi,

I currently have a validation rule running whereby it will only allow a code
that starts with LR and is 6 character long i.e.

LR8976

I need it to allow for either 6 or 9, or allow for between 6 and 9.
Preferably one or the other as it leaves less room for error.

Can you help?


Maybe...

for either 6 or 9

=AND(CODE(A1)=76,CODE(MID(A1,2,1))=82,OR(LEN(A1)=6 ,LEN(A1)=9))

or, for between 6 and 9

=AND(CODE(A1)=76,CODE(MID(A1,2,1))=82,LEN(A1)=6,L EN(A1)<=9)

assuming entry into A1.

Ken Johnson

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Validation - Precede with LR and between 6 and 9 characters lo

On May 8, 9:29 pm, forevertrying
wrote:
Hi Ken,

Will this notice whether or not there is an "LR" at the beginning?


Hi,

If A1 doesn't start with uppercase L then CODE(A1) = 76 is FALSE and
entry is not valid. CODE(A1) returns the ASCII code of only the first
character in A1.
Similarly, if the second character in A1 is not uppercase R then
CODE(MID(A1,2,1))=82 is FALSE and entry is not valid.

If uppercase is not essential then you could use...

=AND(LEFT(A1,2)="LR",OR(LEN(A1)=6,LEN(A1)=9))

OR

=AND(LEFT(A1,2)="LR",LEN(A1)=6,LEN(A1)<=9)

because the LEFT function is not case sensitive.

Ken Johnson


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default Validation - Precede with LR and between 6 and 9 characters lo

Sorry, but half of that last one went straight over my head.

Firstly, A1... is that the cell reference? Mine would be b9 as that is where
I am trying to put the validation, is that right?

Secondly, do i need to sit and manually put each validation code in for each
cell I want it to apply to? Surely there's a quicker way??

Kind Regards



"Ken Johnson" wrote:

On May 8, 9:29 pm, forevertrying
wrote:
Hi Ken,

Will this notice whether or not there is an "LR" at the beginning?


Hi,

If A1 doesn't start with uppercase L then CODE(A1) = 76 is FALSE and
entry is not valid. CODE(A1) returns the ASCII code of only the first
character in A1.
Similarly, if the second character in A1 is not uppercase R then
CODE(MID(A1,2,1))=82 is FALSE and entry is not valid.

If uppercase is not essential then you could use...

=AND(LEFT(A1,2)="LR",OR(LEN(A1)=6,LEN(A1)=9))

OR

=AND(LEFT(A1,2)="LR",LEN(A1)=6,LEN(A1)<=9)

because the LEFT function is not case sensitive.

Ken Johnson

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,073
Default Validation - Precede with LR and between 6 and 9 characters lo

On May 9, 12:22 am, forevertrying
wrote:
Sorry, but half of that last one went straight over my head.

Firstly, A1... is that the cell reference? Mine would be b9 as that is where
I am trying to put the validation, is that right?

Secondly, do i need to sit and manually put each validation code in for each
cell I want it to apply to? Surely there's a quicker way??

Kind Regards

"Ken Johnson" wrote:
On May 8, 9:29 pm, forevertrying
wrote:
Hi Ken,


Will this notice whether or not there is an "LR" at the beginning?


Hi,


If A1 doesn't start with uppercase L then CODE(A1) = 76 is FALSE and
entry is not valid. CODE(A1) returns the ASCII code of only the first
character in A1.
Similarly, if the second character in A1 is not uppercase R then
CODE(MID(A1,2,1))=82 is FALSE and entry is not valid.


If uppercase is not essential then you could use...


=AND(LEFT(A1,2)="LR",OR(LEN(A1)=6,LEN(A1)=9))


OR


=AND(LEFT(A1,2)="LR",LEN(A1)=6,LEN(A1)<=9)


because the LEFT function is not case sensitive.


Ken Johnson


Hi,

I was assuming that the cell to which data validation was being
applied was A1, only because there was no mention of the cell or cells
you were working with.

You say you are trying to put the validation in B9, so just replace
all of the A1s with B9.

No you don't have to go through the same tedious steps for every cell
separately. You first select all of the cells that you are wanting to
be validated before going Data|Validation to bring up the Data
Validation dialog.
When you select more than one cell, all of the selected cells bar one
are shaded.
The unshaded cell is referred to as the active cell.
For example, if you click on B9 then drag down to B18, B10:B18 will be
shaded and B9 will be unshaded because it is the active cell.
Another example, if you hold down the Ctrl key while you click B9,
then D9 (no dragging, just clicking), then F9 in that order; B9 and D9
will be shaded and F9 will be unshaded because it is the active cell.
So, after you have selected all of the cells to be validated with the
same Custom Formula, and you have noted the address of the active
cell, you use the active cell's address when typing the Custom Formula
into the Formula: box on the Data Validation dialog.
Excel automatically adjusts that address for each of the validated
cells.
An important thing to remember is to use the relative column and
relative row form of the active cell's address ie no $ signs.
Excel doesn't change the address' column label if there is a $ sign
before it, and the same goes for the row label.
So, if B9 turns out to be the active cell after you have selected all
the cells to be validated then use B9 in the formula.
If the cells to be validated are not contiguous (selected using Ctrl-
Click) then the active cell will be the last cell you Ctrl-Click and
you will need to use its address in the formula.

Ken Johnson


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove characters in a cell that precede a specific hyphen brantty Excel Discussion (Misc queries) 18 July 25th 08 09:04 AM
Data Validation and a Long List. An Easier Way? [email protected] Excel Discussion (Misc queries) 0 August 24th 07 04:40 PM
Formula too Long for List Validation JB Excel Discussion (Misc queries) 3 April 6th 07 07:11 PM
Format single column cells to be 6 characters long bubberz Excel Worksheet Functions 2 September 12th 05 07:58 PM
last digit in string gets changed to 0 (16 characters long) Mike Milmoe Excel Discussion (Misc queries) 3 June 29th 05 03:36 PM


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"