PC Review


Reply
Thread Tools Rate Thread

Data Validation starts change event

 
 
Kristen
Guest
Posts: n/a
 
      21st Feb 2008
Hi - I currently have a change event for a column (D) with rows less than
500. I also use a data validation in that column for the end user to select
form a drop down list. Depending on their choice, more rows are inserted
below the drop down. I would like the end user to be able to manually add to
column D if they desire without the hcnage event starting.

Is there any way to restrict a change event to only occur when a choice is
selected from a data validation drop down list?
--
Thanks - K
 
Reply With Quote
 
 
 
 
Kristen
Guest
Posts: n/a
 
      21st Feb 2008
I've thought this through and have been checkng the message boards some more.
I think if I could check the value of the cell that was changed and validate
if it is on the list (another worksheet in same workbook) and if it is launch
the macro. I am now having problems detrmining how to write if a cell equals
one of the values of another range of cells then launch the sub. If anyone
could help, I would appreciate it.
--
Thanks - K


"Kristen" wrote:

> Hi - I currently have a change event for a column (D) with rows less than
> 500. I also use a data validation in that column for the end user to select
> form a drop down list. Depending on their choice, more rows are inserted
> below the drop down. I would like the end user to be able to manually add to
> column D if they desire without the hcnage event starting.
>
> Is there any way to restrict a change event to only occur when a choice is
> selected from a data validation drop down list?
> --
> Thanks - K

 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      22nd Feb 2008
Hi Kristen

The code below would be one way of doing what you want. It will take
the value entered in the changed cell and then search for that value
in a given range on sheet3, if the value is found it will show a
msgbox (replace this code with a call to your own macro) if not it
won't do anything.

Paste the code below into the module for the worksheet you are working
on.

Option Explicit
Dim FoundCell, MyRng As Range

Private Sub Worksheet_Change(ByVal Target As Range)

Set MyRng = Worksheets("Sheet3").[A1:A20]

Set FoundCell = Worksheets("Sheet3").Cells.Find _
(What:=Target.Value, LookAt:=xlWhole)

If Not FoundCell Is Nothing Then

MsgBox Target.Value & " was found in the list on sheet3"

End If

End Sub

Hope this helps

Steve
 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      22nd Feb 2008
Hi Again Kristen

Sorry there is a reference to a range in the previous code that is not
required, i forgot to remove it before posting... the code below is
correct...

Option Explicit
Dim FoundCell As Range

Private Sub Worksheet_Change(ByVal Target As Range)

Set FoundCell = Worksheets("Sheet3").Cells.Find _
(What:=Target.Value, LookAt:=xlWhole)

If Not FoundCell Is Nothing Then

MsgBox Target.Value & " was found in the list on sheet3"

End If

End Sub

Steve

 
Reply With Quote
 
Kristen
Guest
Posts: n/a
 
      22nd Feb 2008
Thanks for all of your help. I just tried it on a sample and it looks like
it is exactly what I wanted. I have bought a couple of books, but there is
still alot that the books don't include and I have been tryiing to figure out.

You have been a huge help!
--
Thanks - K


"Incidental" wrote:

> Hi Again Kristen
>
> Sorry there is a reference to a range in the previous code that is not
> required, i forgot to remove it before posting... the code below is
> correct...
>
> Option Explicit
> Dim FoundCell As Range
>
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> Set FoundCell = Worksheets("Sheet3").Cells.Find _
> (What:=Target.Value, LookAt:=xlWhole)
>
> If Not FoundCell Is Nothing Then
>
> MsgBox Target.Value & " was found in the list on sheet3"
>
> End If
>
> End Sub
>
> Steve
>
>

 
Reply With Quote
 
Kristen
Guest
Posts: n/a
 
      22nd Feb 2008
OK. It worked and now it does not. I don't know what I did. I'm pasting
below the code that is in my worksheet, not module.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim foundCell As Range

Set foundCell = Worksheets("All Items").Cells.Find _
(What:=Target.Value, LookAt:=xlWhole)

If Not foundCell Is Nothing Then
MsgBox Target.Value


End If


End Sub



--
Thanks - K


"Kristen" wrote:

> Thanks for all of your help. I just tried it on a sample and it looks like
> it is exactly what I wanted. I have bought a couple of books, but there is
> still alot that the books don't include and I have been tryiing to figure out.
>
> You have been a huge help!
> --
> Thanks - K
>
>
> "Incidental" wrote:
>
> > Hi Again Kristen
> >
> > Sorry there is a reference to a range in the previous code that is not
> > required, i forgot to remove it before posting... the code below is
> > correct...
> >
> > Option Explicit
> > Dim FoundCell As Range
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> >
> > Set FoundCell = Worksheets("Sheet3").Cells.Find _
> > (What:=Target.Value, LookAt:=xlWhole)
> >
> > If Not FoundCell Is Nothing Then
> >
> > MsgBox Target.Value & " was found in the list on sheet3"
> >
> > End If
> >
> > End Sub
> >
> > Steve
> >
> >

 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      25th Feb 2008
Hi Kristen

I have looked at the code and it still works fine the only thing i can
think of is if you have the code in the right place? This code should
be in the module for the worksheet that you will be using i.e. if you
are running the code from sheet1 the code will need to be in the
module for sheet1. and if you are checking the exact sheet (i.e. "All
Items") make sure the name is spelt exactly as it is in your find
code.

Steve
 
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
Worksheet Change event on different ranges with data validation Savalou Dave Microsoft Excel Programming 2 6th Mar 2009 10:46 PM
Worksheet change event for data validation?? =?Utf-8?B?TWVsdGFk?= Microsoft Excel Programming 5 1st Aug 2006 03:56 PM
Data Validation Listbox and the Worksheet Change Event =?Utf-8?B?UkFTRU5U?= Microsoft Excel Programming 0 17th Jun 2005 09:26 PM
Change event for data validation listbox =?Utf-8?B?U3RldmUgUGFya2luc29u?= Microsoft Excel Programming 4 14th Jan 2005 02:57 PM
Data Validation & ControlSource & Change event Ocker Microsoft Excel Programming 4 5th Nov 2004 03:34 AM


Features
 

Advertising
 

Newsgroups
 


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