PC Review


Reply
Thread Tools Rate Thread

Data Validation using multiple columns

 
 
=?Utf-8?B?Qm9i?=
Guest
Posts: n/a
 
      5th Apr 2007
In a Data Validation dropdown, I need to display more than one column of
data, but only "store" the value from the first column? For example:

Column A = ID Number (4 characters long)
Column B = Last Name
Column C = First Name
Column D = Column A & “ “ & Column B & “ “ & Column C
Column E = Data Validation where Source = $D1:$D20

When a user clicks on the Data Validation dropdown arrow, the dropdown would
display the ID Number, Last Name, and First Name. But once a person is
selected, only the ID Number would be "stored" in the cell.

“excelent” was kind enough to provide me with the following macro:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("E6:E20")) Is Nothing Then Exit Sub
Target = Left(Target, 4)
End Sub

Unfortunately, after I select a name from the dropdown list, the list stays
open and Excel appears to lock up until I press the Esc key. Then I get a
"Code execution has been interrupted" error message.

Can anyone tell me how to modify the macro above so that it works properly?
Any help would be greatly appreciated.
Bob

 
Reply With Quote
 
 
 
 
Debra Dalgleish
Guest
Posts: n/a
 
      5th Apr 2007
There's a sample file here that you could adapt:

http://www.contextures.com/excelfiles.html

Under Data Validation, look for 'DV0004 - Data Validation Change'

Bob wrote:
> In a Data Validation dropdown, I need to display more than one column of
> data, but only "store" the value from the first column? For example:
>
> Column A = ID Number (4 characters long)
> Column B = Last Name
> Column C = First Name
> Column D = Column A & “ “ & Column B & “ “ & Column C
> Column E = Data Validation where Source = $D1:$D20
>
> When a user clicks on the Data Validation dropdown arrow, the dropdown would
> display the ID Number, Last Name, and First Name. But once a person is
> selected, only the ID Number would be "stored" in the cell.
>
> “excelent” was kind enough to provide me with the following macro:
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Intersect(Target, Range("E6:E20")) Is Nothing Then Exit Sub
> Target = Left(Target, 4)
> End Sub
>
> Unfortunately, after I select a name from the dropdown list, the list stays
> open and Excel appears to lock up until I press the Esc key. Then I get a
> "Code execution has been interrupted" error message.
>
> Can anyone tell me how to modify the macro above so that it works properly?
> Any help would be greatly appreciated.
> Bob
>



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

 
Reply With Quote
 
=?Utf-8?B?Qm9i?=
Guest
Posts: n/a
 
      5th Apr 2007
Debra,
Thanks for the tip! Since I am a VBA novice, may I ask you two quick
questions?
The range of my "lookup" table is K4:L12. So would I change your line of
code from:

Target.Value = Worksheets("Codes").Range("A1")

to:

Target.Value = Worksheets("Codes").Range("K4:L12")?

Also, given my different lookup range, would the "0), 0)" in the line:

..Match(Target.Value, Worksheets("Codes").Range("ProdList"), 0), 0)

remain the same?

Thanks again for all your help.
Regards,
Bob


"Debra Dalgleish" wrote:

> There's a sample file here that you could adapt:
>
> http://www.contextures.com/excelfiles.html
>
> Under Data Validation, look for 'DV0004 - Data Validation Change'
>
> Bob wrote:
> > In a Data Validation dropdown, I need to display more than one column of
> > data, but only "store" the value from the first column? For example:
> >
> > Column A = ID Number (4 characters long)
> > Column B = Last Name
> > Column C = First Name
> > Column D = Column A & “ “ & Column B & “ “ & Column C
> > Column E = Data Validation where Source = $D1:$D20
> >
> > When a user clicks on the Data Validation dropdown arrow, the dropdown would
> > display the ID Number, Last Name, and First Name. But once a person is
> > selected, only the ID Number would be "stored" in the cell.
> >
> > “excelent” was kind enough to provide me with the following macro:
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Intersect(Target, Range("E6:E20")) Is Nothing Then Exit Sub
> > Target = Left(Target, 4)
> > End Sub
> >
> > Unfortunately, after I select a name from the dropdown list, the list stays
> > open and Excel appears to lock up until I press the Esc key. Then I get a
> > "Code execution has been interrupted" error message.
> >
> > Can anyone tell me how to modify the macro above so that it works properly?
> > Any help would be greatly appreciated.
> > Bob
> >

>
>
> --
> Debra Dalgleish
> Contextures
> http://www.contextures.com/tiptech.html
>
>

 
Reply With Quote
 
Debra Dalgleish
Guest
Posts: n/a
 
      6th Apr 2007
The line:
Target.Value = Worksheets("Codes").Range("A1")
should change to refer to your starting cell:
Target.Value = Worksheets("Codes").Range("K4")

The line:
.Match(Target.Value, Worksheets("Codes").Range("ProdList"), 0), 0)
shouldn't have to change, assuming you have a sheet named codes, and a
range named ProdList, which is the range of cells with the combined
data, e.g. L4:L12

Bob wrote:
> Debra,
> Thanks for the tip! Since I am a VBA novice, may I ask you two quick
> questions?
> The range of my "lookup" table is K4:L12. So would I change your line of
> code from:
>
> Target.Value = Worksheets("Codes").Range("A1")
>
> to:
>
> Target.Value = Worksheets("Codes").Range("K4:L12")?
>
> Also, given my different lookup range, would the "0), 0)" in the line:
>
> .Match(Target.Value, Worksheets("Codes").Range("ProdList"), 0), 0)
>
> remain the same?
>
> Thanks again for all your help.
> Regards,
> Bob
>
>
> "Debra Dalgleish" wrote:
>
>
>>There's a sample file here that you could adapt:
>>
>> http://www.contextures.com/excelfiles.html
>>
>>Under Data Validation, look for 'DV0004 - Data Validation Change'
>>
>>Bob wrote:
>>
>>>In a Data Validation dropdown, I need to display more than one column of
>>>data, but only "store" the value from the first column? For example:
>>>
>>>Column A = ID Number (4 characters long)
>>>Column B = Last Name
>>>Column C = First Name
>>>Column D = Column A & “ “ & Column B & “ “ & Column C
>>>Column E = Data Validation where Source = $D1:$D20
>>>
>>>When a user clicks on the Data Validation dropdown arrow, the dropdown would
>>>display the ID Number, Last Name, and First Name. But once a person is
>>>selected, only the ID Number would be "stored" in the cell.
>>>
>>>“excelent” was kind enough to provide me with the following macro:
>>>
>>>Private Sub Worksheet_Change(ByVal Target As Range)
>>>If Intersect(Target, Range("E6:E20")) Is Nothing Then Exit Sub
>>>Target = Left(Target, 4)
>>>End Sub
>>>
>>>Unfortunately, after I select a name from the dropdown list, the list stays
>>>open and Excel appears to lock up until I press the Esc key. Then I get a
>>>"Code execution has been interrupted" error message.
>>>
>>>Can anyone tell me how to modify the macro above so that it works properly?
>>>Any help would be greatly appreciated.
>>>Bob
>>>

>>
>>
>>--
>>Debra Dalgleish
>>Contextures
>>http://www.contextures.com/tiptech.html
>>
>>

>



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

 
Reply With Quote
 
=?Utf-8?B?Qm9i?=
Guest
Posts: n/a
 
      6th Apr 2007
Debra,
Thanks for all your help! I sincerely appreciate it.
Regards,
Bob


"Debra Dalgleish" wrote:

> The line:
> Target.Value = Worksheets("Codes").Range("A1")
> should change to refer to your starting cell:
> Target.Value = Worksheets("Codes").Range("K4")
>
> The line:
> .Match(Target.Value, Worksheets("Codes").Range("ProdList"), 0), 0)
> shouldn't have to change, assuming you have a sheet named codes, and a
> range named ProdList, which is the range of cells with the combined
> data, e.g. L4:L12
>
> Bob wrote:
> > Debra,
> > Thanks for the tip! Since I am a VBA novice, may I ask you two quick
> > questions?
> > The range of my "lookup" table is K4:L12. So would I change your line of
> > code from:
> >
> > Target.Value = Worksheets("Codes").Range("A1")
> >
> > to:
> >
> > Target.Value = Worksheets("Codes").Range("K4:L12")?
> >
> > Also, given my different lookup range, would the "0), 0)" in the line:
> >
> > .Match(Target.Value, Worksheets("Codes").Range("ProdList"), 0), 0)
> >
> > remain the same?
> >
> > Thanks again for all your help.
> > Regards,
> > Bob
> >
> >
> > "Debra Dalgleish" wrote:
> >
> >
> >>There's a sample file here that you could adapt:
> >>
> >> http://www.contextures.com/excelfiles.html
> >>
> >>Under Data Validation, look for 'DV0004 - Data Validation Change'
> >>
> >>Bob wrote:
> >>
> >>>In a Data Validation dropdown, I need to display more than one column of
> >>>data, but only "store" the value from the first column? For example:
> >>>
> >>>Column A = ID Number (4 characters long)
> >>>Column B = Last Name
> >>>Column C = First Name
> >>>Column D = Column A & “ “ & Column B & “ “ & Column C
> >>>Column E = Data Validation where Source = $D1:$D20
> >>>
> >>>When a user clicks on the Data Validation dropdown arrow, the dropdown would
> >>>display the ID Number, Last Name, and First Name. But once a person is
> >>>selected, only the ID Number would be "stored" in the cell.
> >>>
> >>>“excelent” was kind enough to provide me with the following macro:
> >>>
> >>>Private Sub Worksheet_Change(ByVal Target As Range)
> >>>If Intersect(Target, Range("E6:E20")) Is Nothing Then Exit Sub
> >>>Target = Left(Target, 4)
> >>>End Sub
> >>>
> >>>Unfortunately, after I select a name from the dropdown list, the list stays
> >>>open and Excel appears to lock up until I press the Esc key. Then I get a
> >>>"Code execution has been interrupted" error message.
> >>>
> >>>Can anyone tell me how to modify the macro above so that it works properly?
> >>>Any help would be greatly appreciated.
> >>>Bob
> >>>
> >>
> >>
> >>--
> >>Debra Dalgleish
> >>Contextures
> >>http://www.contextures.com/tiptech.html
> >>
> >>

> >

>
>
> --
> Debra Dalgleish
> Contextures
> http://www.contextures.com/tiptech.html
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
data validation across multiple columns AKrobbins Microsoft Excel Worksheet Functions 1 6th May 2011 04:15 PM
Data Validation on multiple columns NDBC Microsoft Excel Misc 3 19th Aug 2009 03:22 AM
Data Validation & multiple columns =?Utf-8?B?Qm9i?= Microsoft Excel Misc 1 9th Apr 2007 10:24 AM
Data Validation & multiple columns =?Utf-8?B?Qm9i?= Microsoft Excel Programming 6 5th Apr 2007 01:46 PM
Data validation for Multiple columns NC Microsoft Excel Misc 2 11th May 2005 01:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:38 AM.