Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Data Validation twist

Hi,

Is there a way, for a data validation based on a List, to only input
the first character of the selected choice ?
TIA
Carim

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Data Validation twist

Sorry ...

I meant without VBA ...
otherwise with worksheet change event
ActiveCell.Value = Left(ActiveCell.Value, 1)

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Data Validation twist

Hi Carim,

This should input the first character in a DV list for any cell on the sheet
that has a DV list.

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo done:
If Target(1).Validation.Type = xlValidateList Then
Application.EnableEvents = False
Target(1) = Left(Target(1), 1)
End If
done:
Application.EnableEvents = True
End Sub

If you don't want this to affect all DV list cells on the sheet, you will
need to perform some other check on the Target to limit the change.

Regards,
Peter T


"Carim" wrote in message
ups.com...
Hi,

Is there a way, for a data validation based on a List, to only input
the first character of the selected choice ?
TIA
Carim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Data Validation twist

No.

--
Regards,
Tom Ogilvy

"Carim" wrote in message
ups.com...
Sorry ...

I meant without VBA ...
otherwise with worksheet change event
ActiveCell.Value = Left(ActiveCell.Value, 1)

Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Data Validation twist

Peter,

Thanks a lot.
I did not know about the validation.type
Your fix is perfect.
Thanks again.
Cheers
Carim



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Data Validation twist

Thanks Tom ...

I know the value of your "No"
It saves me a lot of time.

Cheers
Carim

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Data Validation twist

I'm confused?

I thought you said:

I meant without VBA ...


then you seemed to say you knew how to do it using an event.

As to Peter's second comment, If you only want to do it on one cell (which
is what you question sounded like), you don't need to even check if it has
validation.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$9" then
if len(Target.Value) 1 then
Target.Value = Left(Target.Value,1)
End if
end If
End Sub

and for completeness, in xl97, the change event does not fire when a value
is selected from a data validation dropdown when the list is filled from a
worksheet.

--
Regards,
Tom Ogilvy

"Carim" wrote in message
ups.com...
Peter,

Thanks a lot.
I did not know about the validation.type
Your fix is perfect.
Thanks again.
Cheers
Carim



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Data Validation twist

Tom,

Sorry for my english ... I am a French native.
You are right, I meant I had a feasible with VBA with XL2000, but did
not know how to do it with a "validation-custom-formula" twist ...
Thanks again for your valuable comments
Best Regards
Carim

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
custom data validation on cells with data validation values AKrobbins Excel Worksheet Functions 2 June 21st 11 04:20 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
Add Column Data with Twist John Excel Worksheet Functions 3 June 25th 06 08:42 AM
normalizing data -- a twist Brad Excel Worksheet Functions 6 June 4th 05 03:42 PM
A new twist to the validation drop-down width question. Spongebob Excel Discussion (Misc queries) 2 May 26th 05 09:12 PM


All times are GMT +1. The time now is 01:45 AM.

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

About Us

"It's about Microsoft Excel"