View Single Post
  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default Custom Validation

Target represents the range you just changed.

If target.cells.count 1 then exit sub

means that if you changed more than one cell then get out of the subroutine.

You can change more than one cell by selecting a multicell range and typing
something, then hitting ctrl-enter--or hitting the delete key to clear the
contents.

If you want to limit the range to inspect to a single cell, you could use:

if target.address < "$B$9" then exit sub

But if you're going to keep adding more and more cells to check, then I find it
easier to just look to see if the intersection (the cells in common in both
ranges) is actually something.

if intersect(target,me.range("a:a,b13:c99,e44")) is nothing then...

would check all of column A, b13:c99 and E44.

Do you remember your Venn diagrams from math?
If the two circles don't overlap at all, then the intersection is nothing.



tkaplan wrote:

Thanks Dave for your help.

I am usually pretty okay with macros but there are some key words that
i dont know what they are and that prevents me from knowing how to do
these things.

This works perfectly (i actually added a line that puts the truncated
text into the next line). can you please explain to me the following
lines of code from your code below so that i can better understand
what's happening?

If Target.Cells.Count 1 Then Exit Sub --what does target.cells.count
test for?

If Intersect(Target, Me.Range("b9")) Is Nothing Then Exit Sub -- what
is intersect function check for?

also, what is vbLf?

Thank you so much for your assistance.
tkaplan

--
tkaplan
------------------------------------------------------------------------
tkaplan's Profile: http://www.excelforum.com/member.php...o&userid=22987
View this thread: http://www.excelforum.com/showthread...hreadid=483601


--

Dave Peterson