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

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Validation List

Right click the sheet tabView Code. This will take you to the code module of
the sheet. Paste the below code which is the change event . Target is the
cell reference.

If your validation drop down range is A1:A100

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
Msgbox "Change has occured"
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

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

I would use code something like this. It assumes your validation list
contains 'This' and 'That'. Right click the sheet tab and select view code.
Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$5" Then
Select Case Target.Value
Case "This"
MsgBox "A"
Case "That"
MsgBox "B"
Case Else
MsgBox "C"
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Validation List

Jacob,

Thank you very much for your help. Your code works perfectly, except one
small thing. Somehow, my code still executes without the value changes in C5.

For example, C5 has value "1234". If I click on the Validation List without
selecting a new value (just by selecting the same value 1234), the code still
executes. Is there a way not to let the code to execute when the value is
the same as before? Basically, the code should only execute when the value
changes from 1234 to 5675?

Thanks.

"Jacob Skaria" wrote:

Right click the sheet tabView Code. This will take you to the code module of
the sheet. Paste the below code which is the change event . Target is the
cell reference.

If your validation drop down range is A1:A100

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
Msgbox "Change has occured"
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Validation List

Jim,

Thank you very much for your help. For what I need now, the same code is
executed regardless of what value is selected from the list. Therefore, the
code only executes when the value is changed from the list.

I will keep your code for furture reference.

Thanks again.

"Jim Thomlinson" wrote:

I would use code something like this. It assumes your validation list
contains 'This' and 'That'. Right click the sheet tab and select view code.
Paste the following...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$5" Then
Select Case Target.Value
Case "This"
MsgBox "A"
Case "That"
MsgBox "B"
Case Else
MsgBox "C"
End Select
End If
End Sub
--
HTH...

Jim Thomlinson


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Validation List

Right click the sheet tab. Remove the existing code and paste the below code.
There are two event codes and 1 variable declared outside the events. Try and
feedback

Dim varTemp As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
If Target.Text < varTemp Then
MsgBox "Change has occured"
End If
End If
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
varTemp = Target.Text
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Jacob,

Thank you very much for your help. Your code works perfectly, except one
small thing. Somehow, my code still executes without the value changes in C5.

For example, C5 has value "1234". If I click on the Validation List without
selecting a new value (just by selecting the same value 1234), the code still
executes. Is there a way not to let the code to execute when the value is
the same as before? Basically, the code should only execute when the value
changes from 1234 to 5675?

Thanks.

"Jacob Skaria" wrote:

Right click the sheet tabView Code. This will take you to the code module of
the sheet. Paste the below code which is the change event . Target is the
cell reference.

If your validation drop down range is A1:A100

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
Msgbox "Change has occured"
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Validation List

Jacob,

Thank you very much for continuing to help.

I tried your updated code, and somehow, the updated or previous code is no
longer executed. When I change the value, nothing happens.

I don't know it is caused by my other code. I have one other code that does
the similar thing, except it has a few lines than the one that you are
helping me. Plus, the other code is executed after I click the command
button so it does not run automatically like the one that you are helping me.


Basically, the other code is looking up the value in Cell C4 and populates
Cell C5 (the cell that you are helping me) via vlookup (for the first value
and the other values are in Validation List). Then it executes the same code
as C5. The one that you have been helping me is to execute the code if the
users change the value from Validation List in C5.

I hope I did not confuse you. Please ask me with questions.

Thanks again.

"Jacob Skaria" wrote:

Right click the sheet tab. Remove the existing code and paste the below code.
There are two event codes and 1 variable declared outside the events. Try and
feedback

Dim varTemp As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
If Target.Text < varTemp Then
MsgBox "Change has occured"
End If
End If
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
varTemp = Target.Text
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Jacob,

Thank you very much for your help. Your code works perfectly, except one
small thing. Somehow, my code still executes without the value changes in C5.

For example, C5 has value "1234". If I click on the Validation List without
selecting a new value (just by selecting the same value 1234), the code still
executes. Is there a way not to let the code to execute when the value is
the same as before? Basically, the code should only execute when the value
changes from 1234 to 5675?

Thanks.

"Jacob Skaria" wrote:

Right click the sheet tabView Code. This will take you to the code module of
the sheet. Paste the below code which is the change event . Target is the
cell reference.

If your validation drop down range is A1:A100

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
Msgbox "Change has occured"
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Validation List

As per the code I pasted earlier the validation list should be in the range
A1:A100. Try that in a fresh workbook and see OR in immediate window you can
execute the below command...

Application.EnableEvents = True


If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Jacob,

Thank you very much for continuing to help.

I tried your updated code, and somehow, the updated or previous code is no
longer executed. When I change the value, nothing happens.

I don't know it is caused by my other code. I have one other code that does
the similar thing, except it has a few lines than the one that you are
helping me. Plus, the other code is executed after I click the command
button so it does not run automatically like the one that you are helping me.


Basically, the other code is looking up the value in Cell C4 and populates
Cell C5 (the cell that you are helping me) via vlookup (for the first value
and the other values are in Validation List). Then it executes the same code
as C5. The one that you have been helping me is to execute the code if the
users change the value from Validation List in C5.

I hope I did not confuse you. Please ask me with questions.

Thanks again.

"Jacob Skaria" wrote:

Right click the sheet tab. Remove the existing code and paste the below code.
There are two event codes and 1 variable declared outside the events. Try and
feedback

Dim varTemp As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
If Target.Text < varTemp Then
MsgBox "Change has occured"
End If
End If
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
varTemp = Target.Text
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Jacob,

Thank you very much for your help. Your code works perfectly, except one
small thing. Somehow, my code still executes without the value changes in C5.

For example, C5 has value "1234". If I click on the Validation List without
selecting a new value (just by selecting the same value 1234), the code still
executes. Is there a way not to let the code to execute when the value is
the same as before? Basically, the code should only execute when the value
changes from 1234 to 5675?

Thanks.

"Jacob Skaria" wrote:

Right click the sheet tabView Code. This will take you to the code module of
the sheet. Paste the below code which is the change event . Target is the
cell reference.

If your validation drop down range is A1:A100

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Not Application.Intersect(Target, Range("A1:A100")) Is Nothing Then
Msgbox "Change has occured"
End If
Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Accesshelp" wrote:

Hello all,

In Cell C5 of my Excel worksheet, I have a Validation List. There are
values in the Validation List, and when the users select a value from the
Validation List, I want my code to perform a list of procedures.

How should I write a code to triggle my code to run when the users select a
value from the Validation List or change a value from previously selected?

From Help, I saw the following event:

Private Sub object_DropButtonClick( )

I don't know the above event would work. What should I have in place of
object in event? ValidateList?

Thanks.

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
Use VBA to reset data validation (=list) value to first value in that list (list is a named range) ker_01 Excel Programming 7 October 27th 08 03:13 PM
Crazy Data Validation ... List Validation Not Working TW Bake Excel Programming 1 March 29th 07 02:41 AM
Validation (Drop down list vs simple text length validation) Bob Phillips[_6_] Excel Programming 2 April 27th 04 07:47 PM
Validation (Drop down list vs simple text length validation) Jason Morin[_2_] Excel Programming 1 April 27th 04 04:56 PM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


All times are GMT +1. The time now is 03:19 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"