Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Cell Format Check

I need a macro to check each cell in a range to see if it fits a
certain format. Specifically the format is

LLNNNNNNL

L = letter
N = number

Is there any easy way to do this?

Thanks,
Richard

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell Format Check


s = "[A-Z][A-Z]#####[A-Z]"
for each cell in selection
if ucase(cell.Value) like s then


End if
Next

Demo'd from the immediate window:

s = "[A-Z][A-Z]#####[A-Z]"
? "AA12345B" like s
True
? "A012345B" like s
False
? "AA123456" like s
False
? "AA1234B" like s
False

--
Regards,
Tom Ogilvy


"Rich" wrote:

I need a macro to check each cell in a range to see if it fits a
certain format. Specifically the format is

LLNNNNNNL

L = letter
N = number

Is there any easy way to do this?

Thanks,
Richard


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cell Format Check

Miscounted the N's

Change it to

s = "[A-Z][A-Z]######[A-Z]"

with 6 #'s

concept is the same.

Just for completeness, if you don't want to include the Ucase, you can be
case insensitive with

s = "[A-Za-z][A-Za-z]######[A-Za-z]"

or to be case sensitive, use the original and don't use the ucase.

--
Regards,
Tom Ogilvy



"Tom Ogilvy" wrote:


s = "[A-Z][A-Z]#####[A-Z]"
for each cell in selection
if ucase(cell.Value) like s then


End if
Next

Demo'd from the immediate window:

s = "[A-Z][A-Z]#####[A-Z]"
? "AA12345B" like s
True
? "A012345B" like s
False
? "AA123456" like s
False
? "AA1234B" like s
False

--
Regards,
Tom Ogilvy


"Rich" wrote:

I need a macro to check each cell in a range to see if it fits a
certain format. Specifically the format is

LLNNNNNNL

L = letter
N = number

Is there any easy way to do this?

Thanks,
Richard


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Cell Format Check

Excellent

thanks very much

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
check or uncheck a check box based on a cell value RTKCPA Excel Discussion (Misc queries) 1 February 3rd 10 03:11 PM
Copy and move check box (check boxes) with new cell link? Marty Excel Worksheet Functions 1 January 20th 10 07:43 PM
Check if Conditional Format is True or False / Check cell Color Kevin McCartney Excel Worksheet Functions 5 June 29th 07 11:12 AM
check the cell format by function or vba code Joachim[_2_] Excel Programming 1 March 21st 05 12:29 PM
Check cell contents then format as locked Katherine Excel Programming 3 February 1st 05 12:48 PM


All times are GMT +1. The time now is 04:52 AM.

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"