Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default vLookup with comma break

Greetings all,
I have a worksheet where cell B8 and B10 perform a vLookup based on a data
validation in B6:

=IF(B6="","",(VLOOKUP(B6,Position,2,0)))
IF(B6="","",VLOOKUP(B6,AD_Groups,2,0))

I have the following code in place to perform a line break after each comma
in the returned value. It works great the first time, but then anytime I
change or add something to any cell in the range B1:B10 it adds another line
break to B8 and B10. Anything after B10 is fine and doesn't affect the
previous cells. I guess what I'm asking is if there is a way to alter this
code (which I found in a previous posting, just altered my range to B1) so
that it only happens if B6 is selected and changed? And only affects cells
B8 and B10, so any other cells that may have commas are unaffected?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As Range
Dim t As Range
Set t = Target
Set a = Range(Range("B1"), Cells(Rows.Count, 1).End(xlUp))
Dim s1 As String
Dim s2 As String
s1 = ","
s2 = s1 & Chr(10)
If Intersect(t, a) Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each t In a
t.Value = Replace(t.Value, s1, s2)
Next t
Application.EnableEvents = True
End Sub

Also if I try to clear out my cells to start over, my formula's disappear and
I can't add them back. Each time I try the cell just clears itself out
again. I have to alter my range to something like A1, then I can add my
formulas again.

As always I appreciate any help I can get.

--
Jon M.
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
VLookup Method for Comma Delimited Field DoveArrow Excel Discussion (Misc queries) 1 December 22nd 11 12:59 PM
Line break from vLookup Jon M. Excel Programming 1 March 5th 10 03:00 PM
Line Break Vlookup Jon M. Excel Worksheet Functions 2 March 2nd 10 06:30 PM
VLOOKUP Comma Separated Values in Excel 2007? Travis T Excel Programming 0 February 20th 09 04:55 PM
comma seperated values using multiple vlookup TheSniipe Excel Programming 2 March 29th 07 02:14 PM


All times are GMT +1. The time now is 04:24 PM.

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"